Class: EventSourcery::Rails::Command
- Inherits:
-
Object
- Object
- EventSourcery::Rails::Command
- Defined in:
- lib/event_sourcery/rails/command.rb
Instance Attribute Summary collapse
-
#aggregate_id ⇒ Object
readonly
Returns the value of attribute aggregate_id.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(aggregate_id:) ⇒ Command
constructor
A new instance of Command.
Constructor Details
#initialize(aggregate_id:) ⇒ Command
Returns a new instance of Command.
6 7 8 |
# File 'lib/event_sourcery/rails/command.rb', line 6 def initialize(aggregate_id:) @aggregate_id = aggregate_id end |
Instance Attribute Details
#aggregate_id ⇒ Object (readonly)
Returns the value of attribute aggregate_id.
4 5 6 |
# File 'lib/event_sourcery/rails/command.rb', line 4 def aggregate_id @aggregate_id end |
Class Method Details
.attributes(*attributes) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/event_sourcery/rails/command.rb', line 10 def self.attributes(*attributes) attr_reader *attributes method_arguments = attributes.map { |arg| "#{arg}:" }.join(', ') method_assignments = attributes.map { |arg| "@#{arg} = #{arg}" }.join(';') method_attrs_to_hash = attributes.map { |arg| "#{arg}: #{arg}" }.join(',') class_eval " def initialize(aggregate_id:, \#{method_arguments})\n @aggregate_id = aggregate_id\n \#{method_assignments}\n end\n\n def to_hash\n {\#{method_attrs_to_hash}}\n end\n CODE\nend\n" |