Class: Philiprehberger::StateMachine::AutoTransition

Inherits:
Struct
  • Object
show all
Defined in:
lib/philiprehberger/state_machine/auto_transition.rb

Overview

Represents a timed automatic transition.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#afterObject

Returns the value of attribute after

Returns:

  • (Object)

    the current value of after



6
7
8
# File 'lib/philiprehberger/state_machine/auto_transition.rb', line 6

def after
  @after
end

#fromObject

Returns the value of attribute from

Returns:

  • (Object)

    the current value of from



6
7
8
# File 'lib/philiprehberger/state_machine/auto_transition.rb', line 6

def from
  @from
end

#guardObject

Returns the value of attribute guard

Returns:

  • (Object)

    the current value of guard



6
7
8
# File 'lib/philiprehberger/state_machine/auto_transition.rb', line 6

def guard
  @guard
end

#toObject

Returns the value of attribute to

Returns:

  • (Object)

    the current value of to



6
7
8
# File 'lib/philiprehberger/state_machine/auto_transition.rb', line 6

def to
  @to
end

Instance Method Details

#matches?(current_state) ⇒ Boolean

Check if this auto-transition applies to the given state.

Parameters:

  • current_state (Symbol)

Returns:

  • (Boolean)


11
12
13
14
15
16
17
# File 'lib/philiprehberger/state_machine/auto_transition.rb', line 11

def matches?(current_state)
  if from.is_a?(Array)
    from.include?(current_state)
  else
    from == current_state
  end
end