Class: ActiveCommand::Command
- Inherits:
-
Object
- Object
- ActiveCommand::Command
- Includes:
- ActiveModel::Serializers::JSON, ActiveModel::Validations
- Defined in:
- lib/active_command/command.rb
Class Method Summary collapse
Instance Method Summary collapse
- #execute ⇒ Object
- #run ⇒ Object
- #to_params ⇒ Object (also: #to_hash)
Class Method Details
.from_json(json) ⇒ Object
7 8 9 10 11 |
# File 'lib/active_command/command.rb', line 7 def self.from_json(json) klass = self.new klass.from_json(json) klass end |
Instance Method Details
#execute ⇒ Object
26 27 28 |
# File 'lib/active_command/command.rb', line 26 def execute raise NotImplementedError, "#{self.class.name} does not implement an execute method" end |
#run ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/active_command/command.rb', line 18 def run if self.valid? self.execute else raise ActiveCommand::CommandNotValidError, self.errors. end end |
#to_params ⇒ Object Also known as: to_hash
13 14 15 |
# File 'lib/active_command/command.rb', line 13 def to_params ActiveSupport::HashWithIndifferentAccess.new(attributes).delete_if { |k, v| v.nil? } end |