Class: Redde::SystemCommand
- Inherits:
-
Object
- Object
- Redde::SystemCommand
- Defined in:
- app/models/redde/system_command.rb
Constant Summary collapse
- ALLOWED_ACTIONS =
%w(cache unicorn sidekiq reboot).freeze
Instance Attribute Summary collapse
-
#action ⇒ Object
Returns the value of attribute action.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(action) ⇒ SystemCommand
constructor
A new instance of SystemCommand.
- #process ⇒ Object
Constructor Details
#initialize(action) ⇒ SystemCommand
Returns a new instance of SystemCommand.
10 11 12 13 14 |
# File 'app/models/redde/system_command.rb', line 10 def initialize(action) @action = action Logger.new('log/commands.log').info "Received #{action} command" fail "Unsopported command #{action}. Allowed commands: #{ALLOWED_ACTIONS.join(', ')}" unless ALLOWED_ACTIONS.include?(action.to_s) end |
Instance Attribute Details
#action ⇒ Object
Returns the value of attribute action.
2 3 4 |
# File 'app/models/redde/system_command.rb', line 2 def action @action end |
Class Method Details
.execute(action) ⇒ Object
6 7 8 |
# File 'app/models/redde/system_command.rb', line 6 def self.execute(action) new(action).process end |
Instance Method Details
#process ⇒ Object
16 17 18 |
# File 'app/models/redde/system_command.rb', line 16 def process send(action) end |