Class: Eventusha::Command
- Inherits:
-
Object
- Object
- Eventusha::Command
- Includes:
- ActiveModel::Model
- Defined in:
- lib/eventusha/command.rb
Instance Attribute Summary collapse
-
#aggregate_id ⇒ Object
Returns the value of attribute aggregate_id.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#aggregate_id ⇒ Object
Returns the value of attribute aggregate_id.
5 6 7 |
# File 'lib/eventusha/command.rb', line 5 def aggregate_id @aggregate_id end |
Class Method Details
.attributes(*attributes) ⇒ Object
7 8 9 10 11 12 |
# File 'lib/eventusha/command.rb', line 7 def self.attributes(*attributes) attr_accessor *attributes define_method :readable_attributes do attributes end end |
Instance Method Details
#attributes ⇒ Object
25 26 27 28 29 |
# File 'lib/eventusha/command.rb', line 25 def attributes readable_attributes.each_with_object({}) do |attribute, attrs_hash| attrs_hash[attribute] = instance_variable_get("@#{attribute}") end.with_indifferent_access end |
#execute ⇒ Object
14 15 16 17 18 19 |
# File 'lib/eventusha/command.rb', line 14 def execute return false if invalid? command_handler = find_command_handler(self) command_handler.execute(self) end |
#find_command_handler(command) ⇒ Object
21 22 23 |
# File 'lib/eventusha/command.rb', line 21 def find_command_handler(command) "CommandHandlers::#{self.class.name.demodulize}".constantize end |