Module: Foobara::CommandPatternImplementation::Concerns::Callbacks::ClassMethods

Defined in:
foobara-0.2.7/projects/command/src/command_pattern_implementation/concerns/callbacks.rb

Instance Method Summary collapse

Instance Method Details

#remove_all_callbacksObject



26
27
28
29
30
31
# File 'projects/command/src/command_pattern_implementation/concerns/callbacks.rb', line 26

def remove_all_callbacks
  Foobara::Command::StateMachine.remove_all_callbacks
  if defined?(@state_machine_callback_registry)
    remove_instance_variable(:@state_machine_callback_registry)
  end
end

#state_machine_callback_registryObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'projects/command/src/command_pattern_implementation/concerns/callbacks.rb', line 10

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

  @state_machine_callback_registry = if superclass.respond_to?(:state_machine_callback_registry)
                                       Callback::Registry::ChainedConditioned.new(
                                         superclass.state_machine_callback_registry
                                       )
                                     else
                                       Callback::Registry::Conditioned.new(
                                         from: Foobara::Command::StateMachine.states,
                                         transition: Foobara::Command::StateMachine.transitions,
                                         to: Foobara::Command::StateMachine.states
                                       )
                                     end
end