### Home Classes Methods

### In Files

- lib/state_machine/path_collection.rb

### Parent

Array

### Methods

- ::new
- #events
- #from_states
- #to_states

### Included Modules

- StateMachine::Assertions

### Files

- LICENSE

### Class/Module Index

Quicksearch

- StateMachine
- StateMachine::AllMatcher
- StateMachine::Assertions
- StateMachine::AttributeTransitionCollection
- StateMachine::BlacklistMatcher
- StateMachine::Branch
- StateMachine::Callback
- StateMachine::ClassMethods
- StateMachine::Error
- StateMachine::EvalHelpers
- StateMachine::Event
- StateMachine::EventCollection
- StateMachine::Graph
- StateMachine::InstanceMethods
- StateMachine::IntegrationNotFound
- StateMachine::Integrations
- StateMachine::Integrations::ActiveModel
- StateMachine::Integrations::ActiveModel::Observer
- StateMachine::Integrations::ActiveModel::ObserverUpdate
- StateMachine::Integrations::ActiveRecord
- StateMachine::Integrations::Base
- StateMachine::Integrations::Base::ClassMethods
- StateMachine::Integrations::DataMapper
- StateMachine::Integrations::DataMapper::Observer
- StateMachine::Integrations::MongoMapper
- StateMachine::Integrations::Mongoid
- StateMachine::Integrations::Sequel
- StateMachine::InvalidEvent
- StateMachine::InvalidParallelTransition
- StateMachine::InvalidTransition
- StateMachine::LoopbackMatcher
- StateMachine::Machine
- StateMachine::MachineCollection
- StateMachine::MacroMethods
- StateMachine::Matcher
- StateMachine::MatcherHelpers
- StateMachine::NodeCollection
- StateMachine::Path
- StateMachine::PathCollection
- StateMachine::RailsEngine
- StateMachine::State
- StateMachine::StateCollection
- StateMachine::StateContext
- StateMachine::Transition
- StateMachine::TransitionCollection
- StateMachine::WhitelistMatcher
- StateMachine::YARD
- StateMachine::YARD::Handlers
- StateMachine::YARD::Handlers::Base
- StateMachine::YARD::Handlers::Event
- StateMachine::YARD::Handlers::Machine
- StateMachine::YARD::Handlers::State
- StateMachine::YARD::Handlers::Transition
- Object

No matching classes.

# StateMachine::PathCollection

Represents a collection of paths that are generated based on a set of requirements regarding what states to start and end on

### Attributes

from_name[R]

The initial state to start each path from

machine[R]

The state machine these path are walking

object[R]

The object whose state machine is being walked

to_name[R]

The target state for each path

### Public Class Methods

new(object, machine, options = {}) click to toggle source

Creates a new collection of paths with the given requirements.

Configuration options:

- `:from` - The initial state to start from

- `:to` - The target end state

- `:deep` - Whether to enable deep searches for the target state.

- `:guard` - Whether to guard transitions with the if/unless conditionals defined for each one

    # File lib/state_machine/path_collection.rb, line 29
    def initialize(object, machine, options = {})
      options = {:deep => false, :from => machine.states.match!(object).name}.merge(options)
      assert_valid_keys(options, :from, :to, :deep, :guard)

      @object = object
      @machine = machine
      @from_name = machine.states.fetch(options[:from]).name
      @to_name = options[:to] && machine.states.fetch(options[:to]).name
      @guard = options[:guard]
      @deep = options[:deep]

      initial_paths.each {|path| walk(path)}
    end

### Public Instance Methods

events() click to toggle source

Lists all of the events that can be fired through the paths in this collection.

For example,

    paths.events  # => [:park, :ignite, :shift_up, ...]

    # File lib/state_machine/path_collection.rb, line 69
    def events
      map {|path| path.events}.flatten.uniq
    end

from_states() click to toggle source

Lists all of the states that can be transitioned from through the paths in this collection.

For example,

    paths.from_states # => [:parked, :idling, :first_gear, ...]

    # File lib/state_machine/path_collection.rb, line 49
    def from_states
      map {|path| path.from_states}.flatten.uniq
    end

to_states() click to toggle source

Lists all of the states that can be transitioned to through the paths in this collection.

For example,

    paths.to_states # => [:idling, :first_gear, :second_gear, ...]

    # File lib/state_machine/path_collection.rb, line 59
    def to_states
      map {|path| path.to_states}.flatten.uniq
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.