Class: EdgycircleToolbox::CQRS::CommandResult

Inherits:
Object
  • Object
show all
Defined in:
lib/edgycircle_toolbox/cqrs/command_result.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#commandObject (readonly)

Returns the value of attribute command.



4
5
6
# File 'lib/edgycircle_toolbox/cqrs/command_result.rb', line 4

def command
  @command
end

#errorsObject (readonly)

Returns the value of attribute errors.



4
5
6
# File 'lib/edgycircle_toolbox/cqrs/command_result.rb', line 4

def errors
  @errors
end

#eventsObject (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

Returns:

  • (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