Class: StateMachine::AlternateMachine

Inherits:
Object
  • Object
show all
Defined in:
lib/call_center/state_machine_ext.rb

Overview

Extension for StateMachine::AlternateMachine to provide render blocks inside a state definition

Instance Method Summary collapse

Instance Method Details

#actor(name, &blk) ⇒ Object



88
89
90
91
92
93
94
# File 'lib/call_center/state_machine_ext.rb', line 88

def actor(name, &blk)
  (class << self; self; end).send(:define_method, name.to_sym) do |event_name, options|
    event_name = :"#{name}_#{event_name}"
    event(event_name, options)
  end
  @queued_sends << [[:flow_actors, name], blk]
end

#after(scope, options = {}, &blk) ⇒ Object



82
83
84
85
86
# File 'lib/call_center/state_machine_ext.rb', line 82

def after(scope, options = {}, &blk)
  if @from_state
    @queued_sends << [[:after, @from_state, scope, options], blk]
  end
end

#before(scope, options = {}, &blk) ⇒ Object



76
77
78
79
80
# File 'lib/call_center/state_machine_ext.rb', line 76

def before(scope, options = {}, &blk)
  if @from_state
    @queued_sends << [[:before, @from_state, scope, options], blk]
  end
end

#response(state_name = nil, &blk) ⇒ Object



68
69
70
71
72
73
74
# File 'lib/call_center/state_machine_ext.rb', line 68

def response(state_name = nil, &blk)
  if @from_state
    @queued_sends << [[:response, @from_state], blk]
  else
    @queued_sends << [[:response, state_name], blk]
  end
end