Class: EdgycircleToolbox::CQRS::CommandResult
- Inherits:
-
Object
- Object
- EdgycircleToolbox::CQRS::CommandResult
- Defined in:
- lib/edgycircle_toolbox/cqrs/command_result.rb
Instance Attribute Summary collapse
-
#command ⇒ Object
readonly
Returns the value of attribute command.
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#events ⇒ Object
readonly
Returns the value of attribute events.
Instance Method Summary collapse
- #add_error(error) ⇒ Object
- #add_event(event) ⇒ Object
- #failure? ⇒ Boolean
-
#initialize(command = nil) ⇒ CommandResult
constructor
A new instance of CommandResult.
- #set_command(command) ⇒ Object
Constructor Details
#initialize(command = nil) ⇒ CommandResult
Returns a new instance of CommandResult.
6 7 8 9 10 |
# File 'lib/edgycircle_toolbox/cqrs/command_result.rb', line 6 def initialize(command = nil) @command = command @events = [] @errors = [] end |
Instance Attribute Details
#command ⇒ Object (readonly)
Returns the value of attribute command.
4 5 6 |
# File 'lib/edgycircle_toolbox/cqrs/command_result.rb', line 4 def command @command end |
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
4 5 6 |
# File 'lib/edgycircle_toolbox/cqrs/command_result.rb', line 4 def errors @errors end |
#events ⇒ Object (readonly)
Returns the value of attribute events.
4 5 6 |
# File 'lib/edgycircle_toolbox/cqrs/command_result.rb', line 4 def events @events end |
Instance Method Details
#add_error(error) ⇒ Object
12 13 14 15 |
# File 'lib/edgycircle_toolbox/cqrs/command_result.rb', line 12 def add_error(error) errors << error self end |
#add_event(event) ⇒ Object
17 18 19 20 |
# File 'lib/edgycircle_toolbox/cqrs/command_result.rb', line 17 def add_event(event) events << event self end |
#failure? ⇒ Boolean
27 28 29 |
# File 'lib/edgycircle_toolbox/cqrs/command_result.rb', line 27 def failure? errors.size > 0 end |
#set_command(command) ⇒ Object
22 23 24 25 |
# File 'lib/edgycircle_toolbox/cqrs/command_result.rb', line 22 def set_command(command) @command = command self end |