Class: Workflow::Event::Transition Private

Inherits:
Object
  • Object
show all
Defined in:
lib/workflow/event.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Represents a possible transition via the event on which it is defined.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(target_state, conditions_def, &block) ⇒ Transition

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Transition.

Parameters:

  • target_state (Symbol)

    the name of the state target state if this transition matches.

  • conditions_def (Hash)


96
97
98
99
# File 'lib/workflow/event.rb', line 96

def initialize(target_state, conditions_def, &block)
  @target_state = target_state
  @conditions = Conditions.new conditions_def, &block
end

Instance Attribute Details

#target_stateWorkflow::State

Returns The target state for this transition.

Returns:



84
85
86
# File 'lib/workflow/event.rb', line 84

def target_state
  @target_state
end

Instance Method Details

#inspectObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



101
102
103
# File 'lib/workflow/event.rb', line 101

def inspect
  "<to=#{target_state.inspect} conditions=#{conditions.inspect}"
end

#matches?(target) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Whether or not the conditions match for the target object.

Parameters:

  • target (Object)

    an object of the class for which this event/transition was defined.

Returns:

  • (Boolean)

    True if all conditions apply.



90
91
92
# File 'lib/workflow/event.rb', line 90

def matches?(target)
  conditions.apply?(target)
end