Module: Foobara::CommandPatternImplementation::Concerns::StateMachine

Included in:
Foobara::CommandPatternImplementation
Defined in:
foobara-0.1.7/projects/command/src/command_pattern_implementation/concerns/state_machine.rb

Instance Method Summary collapse

Instance Method Details

#state_machineObject



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'foobara-0.1.7/projects/command/src/command_pattern_implementation/concerns/state_machine.rb', line 5

def state_machine
  return @state_machine if defined?(@state_machine)

  # It makes me nervous to pass self around. Seems like a design smell.
  @state_machine = Foobara::Command::StateMachine.new(owner: self)

  @state_machine.callback_registry = Callback::Registry::JoinedConditioned.new(
    @state_machine.callback_registry,
    self.class.state_machine_callback_registry
  )

  @state_machine
end