Class: StateStep::StateTrans

Inherits:
Object
  • Object
show all
Defined in:
lib/state_step/state_trans.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(from, to, name, &block) ⇒ StateTrans

Returns a new instance of StateTrans.



8
9
10
11
12
13
# File 'lib/state_step/state_trans.rb', line 8

def initialize(from, to, name, &block)
  @stFrom = from
  @stTo = to
  @action_name = name
  @callback = block
end

Instance Attribute Details

#action_nameObject (readonly)

Returns the value of attribute action_name.



7
8
9
# File 'lib/state_step/state_trans.rb', line 7

def action_name
  @action_name
end

#stFromObject (readonly)

Returns the value of attribute stFrom.



7
8
9
# File 'lib/state_step/state_trans.rb', line 7

def stFrom
  @stFrom
end

#stToObject (readonly)

Returns the value of attribute stTo.



7
8
9
# File 'lib/state_step/state_trans.rb', line 7

def stTo
  @stTo
end

Instance Method Details

#triggerObject



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/state_step/state_trans.rb', line 15

def trigger
  st = @callback.call
  StateStep.logger.debug "st.nil? : #{st.nil?} / st = '#{st}'"
  if st.nil? or st == true
    StateStep.logger.debug "Status changed!"
    @stTo
  else
    StateStep.logger.debug "Status reverted!"
    @stFrom
  end
end