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

- (StateEvent) initialize

Returns a new instance of StateEvent



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

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

Instance Attribute Details

- (Object) transitions (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

- (Object) action(&proc)



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

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

- (Object) run(obj, old_state, new_state)



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

- (Object) transition(params = nil)



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

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