Module: Jsm::Client::ClassMethods

Defined in:
lib/jsm/client.rb

Instance Method Summary collapse

Instance Method Details

#jsm_event_executorObject

define type of event executor to be used



55
56
57
# File 'lib/jsm/client.rb', line 55

def jsm_event_executor
  Jsm::EventExecutor::Base
end

#jsm_use(state_machine) ⇒ Object



32
33
34
35
36
37
38
39
# File 'lib/jsm/client.rb', line 32

def jsm_use(state_machine)
  self.class_eval <<-EODEF, __FILE__, __LINE__
    def self.state_machine
      #{state_machine}
    end
  EODEF
  Jsm::Machines.add_machines(self, state_machine.new(self))
end

#new(*args, &block) ⇒ Object

override method new it is used for set the instance state attribute with initial_state if initial_state present & instance state attribute is nil



44
45
46
47
48
49
50
51
52
# File 'lib/jsm/client.rb', line 44

def new(*args, &block)
  obj = super
  initial_state = self.state_machine.initial_state

  if initial_state && !obj.current_state
    obj.send(:jsm_set_state, initial_state.name)
  end
  obj
end