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)


103
104
105
106
# File 'lib/workflow/event.rb', line 103

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:



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

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.



108
109
110
# File 'lib/workflow/event.rb', line 108

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.



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

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