Class: Spider::Model::StateMachine::ClassMethods::StateEvent

Inherits:
Object
  • Object
show all
Defined in:
lib/spiderfw/model/mixins/state_machine.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeStateEvent



22
23
24
25
# File 'lib/spiderfw/model/mixins/state_machine.rb', line 22

def initialize
    @transitions = []
    @action = nil
end

Instance Attribute Details

#transitionsObject (readonly)

Returns the value of attribute transitions



20
21
22
# File 'lib/spiderfw/model/mixins/state_machine.rb', line 20

def transitions
  @transitions
end

Instance Method Details

#action(&proc) ⇒ Object



31
32
33
34
# File 'lib/spiderfw/model/mixins/state_machine.rb', line 31

def action(&proc)
    @action = proc if proc
    @action
end

#run(obj, old_state, new_state) ⇒ Object



36
37
38
# File 'lib/spiderfw/model/mixins/state_machine.rb', line 36

def run(obj, old_state, new_state)
    @action.call(obj, old_state, new_state)
end

#transition(params = nil) ⇒ Object



27
28
29
# File 'lib/spiderfw/model/mixins/state_machine.rb', line 27

def transition(params=nil)
    @transitions << params if params
end