Module: RMachine

Defined in:
lib/r_machine.rb,
lib/r_machine/rule.rb,
lib/r_machine/event.rb,
lib/r_machine/state_template.rb,
lib/r_machine/state_notifier_factory.rb,
lib/r_machine/notifiers/call_event_method_notifier.rb,
lib/r_machine/notifiers/change_state_value_notifier.rb,
lib/r_machine/state_transaction_not_permitted_error.rb,
lib/r_machine/notifiers/retrieve_state_value_notifier.rb

Defined Under Namespace

Modules: ClassMethods Classes: CallEventMethodNotifier, ChangeStateValueNotifier, Event, RetrieveStateValueNotifier, Rule, StateNotifierFactory, StateTemplate, StateTransactionNotPermittedError

Class Method Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(called_method, *args) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/r_machine.rb', line 15

def method_missing(called_method, *args)
  factory_params = {
    object_called: self,
    state_template: ClassMethods.state_template,
    message_name: called_method,
    message_args: args
  }

  factory = StateNotifierFactory.new factory_params

  if factory.is_notifying_state_machine?
    factory.notifier.notify!
  else
    super
  end
end

Class Method Details

.included(base) ⇒ Object



11
12
13
# File 'lib/r_machine.rb', line 11

def self.included(base)
  base.extend(ClassMethods)
end