Commit f6978895af74f65f563f55bc1cf2d30782ad0f31
1 parent
158cc1d2
Exists in
master
and in
79 other branches
Replaces block conditions to proc.
Signed-off-by: David Carlos <ddavidcarlos1392@gmail.com>
Showing
1 changed file
with
9 additions
and
10 deletions
Show diff stats
controllers/mpog_software_plugin_myprofile_controller.rb
... | ... | @@ -88,12 +88,7 @@ class MpogSoftwarePluginMyprofileController < MyProfileController |
88 | 88 | @list_operating_systems = OperatingSystemHelper.list_operating_system(params[:operating_system]) |
89 | 89 | @software_info.software_categories = @software_categories unless params[:software_categories].nil? |
90 | 90 | |
91 | - if not @list_libraries.nil? | |
92 | - @software_info.libraries.destroy_all | |
93 | - @list_libraries.each do |library| | |
94 | - @software_info.libraries << library | |
95 | - end | |
96 | - end | |
91 | + software_info_insert_models.call(@list_libraries,'libraries') | |
97 | 92 | |
98 | 93 | if not @list_languages.nil? |
99 | 94 | @software_info.software_languages.destroy_all |
... | ... | @@ -128,6 +123,10 @@ class MpogSoftwarePluginMyprofileController < MyProfileController |
128 | 123 | end |
129 | 124 | end |
130 | 125 | |
126 | + def software_info_insert_models | |
127 | + proc { |list,model_attr| @software_info.send(model_attr).destroy_all; list.collect!{|m| @software_info.send(model_attr) << m } unless list.nil? } | |
128 | + end | |
129 | + | |
131 | 130 | def disabled_public_software_field |
132 | 131 | !environment.admins.include?(current_user.person) |
133 | 132 | end |
... | ... | @@ -150,13 +149,13 @@ class MpogSoftwarePluginMyprofileController < MyProfileController |
150 | 149 | end |
151 | 150 | |
152 | 151 | def governmental_updates |
153 | - govPower = GovernmentalPower.find params[:institutions][:governmental_power] | |
154 | - govSphere = GovernmentalSphere.find params[:institutions][:governmental_sphere] | |
152 | + gov_power = GovernmentalPower.find params[:institutions][:governmental_power] | |
153 | + gov_sphere = GovernmentalSphere.find params[:institutions][:governmental_sphere] | |
155 | 154 | jur_nature = JuridicalNature.find params[:institutions][:juridical_nature] |
156 | 155 | |
157 | 156 | @institution.juridical_nature = jur_nature |
158 | - @institution.governmental_power = govPower | |
159 | - @institution.governmental_sphere = govSphere | |
157 | + @institution.governmental_power = gov_power | |
158 | + @institution.governmental_sphere = gov_sphere | |
160 | 159 | @institution.save |
161 | 160 | end |
162 | 161 | ... | ... |