Some remarks inline
* Ladislav Slezak
--- a/plugins/system/app/models/system.rb +++ b/plugins/system/app/models/system.rb @@ -46,11 +46,21 @@ class System case action
when :reboot - Rails.logger.debug 'Rebooting the computer...' - return computer.Reboot == 0 + if ENV['RAILS_ENV'] == 'production' + Rails.logger.debug 'Rebooting the computer...' + return computer.Reboot == 0
'Reboot' seems to be a function. However according to Ruby naming conventions 'Reboot' is a class (first letter upper case).
+ else + Rails.logger.debug "Skipping reboot in #{ENV['RAILS_ENV']} mode" + return true + end
The result of the "when :reboot" case is of boolean type. Let the 'reboot' function also return a boolean and drop the comparison with 0
when :shutdown - Rails.logger.debug 'Shutting down the computer...' - return computer.Shutdown == 0 + if ENV['RAILS_ENV'] == 'production' + Rails.logger.debug 'Shutting down the computer...' + return computer.Shutdown == 0 + else + Rails.logger.debug "Skipping shutdown in #{ENV['RAILS_ENV']} mode" + return true + end
The duplication of the production check is not DRY (don't repeat yourself). Also think about moving the check into the 'reboot' resp. 'shutdown' functions, because this is "where the action is". Klaus --- SUSE LINUX Products GmbH, GF: Markus Rex, HRB 16746 (AG Nürnberg) -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org For additional commands, e-mail: yast-devel+help@opensuse.org