From f6978895af74f65f563f55bc1cf2d30782ad0f31 Mon Sep 17 00:00:00 2001 From: David Carlos Date: Thu, 11 Dec 2014 14:02:21 -0200 Subject: [PATCH] Replaces block conditions to proc. --- controllers/mpog_software_plugin_myprofile_controller.rb | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/controllers/mpog_software_plugin_myprofile_controller.rb b/controllers/mpog_software_plugin_myprofile_controller.rb index c2d7c4d..686cd35 100644 --- a/controllers/mpog_software_plugin_myprofile_controller.rb +++ b/controllers/mpog_software_plugin_myprofile_controller.rb @@ -88,12 +88,7 @@ class MpogSoftwarePluginMyprofileController < MyProfileController @list_operating_systems = OperatingSystemHelper.list_operating_system(params[:operating_system]) @software_info.software_categories = @software_categories unless params[:software_categories].nil? - if not @list_libraries.nil? - @software_info.libraries.destroy_all - @list_libraries.each do |library| - @software_info.libraries << library - end - end + software_info_insert_models.call(@list_libraries,'libraries') if not @list_languages.nil? @software_info.software_languages.destroy_all @@ -128,6 +123,10 @@ class MpogSoftwarePluginMyprofileController < MyProfileController end end + def software_info_insert_models + proc { |list,model_attr| @software_info.send(model_attr).destroy_all; list.collect!{|m| @software_info.send(model_attr) << m } unless list.nil? } + end + def disabled_public_software_field !environment.admins.include?(current_user.person) end @@ -150,13 +149,13 @@ class MpogSoftwarePluginMyprofileController < MyProfileController end def governmental_updates - govPower = GovernmentalPower.find params[:institutions][:governmental_power] - govSphere = GovernmentalSphere.find params[:institutions][:governmental_sphere] + gov_power = GovernmentalPower.find params[:institutions][:governmental_power] + gov_sphere = GovernmentalSphere.find params[:institutions][:governmental_sphere] jur_nature = JuridicalNature.find params[:institutions][:juridical_nature] @institution.juridical_nature = jur_nature - @institution.governmental_power = govPower - @institution.governmental_sphere = govSphere + @institution.governmental_power = gov_power + @institution.governmental_sphere = gov_sphere @institution.save end -- libgit2 0.21.2