### Home Classes Methods

### In Files

- lib/state_machine/matcher_helpers.rb

### Methods

- #all
- #any
- #same

### 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::MatcherHelpers

Provides a set of helper methods for generating matchers

### Public Instance Methods

all() click to toggle source

Represents a state that matches all known states in a machine.

## Examples

    class Vehicle
      state_machine do
        before_transition any => :parked, :do => lambda {...}
        before_transition all - :parked => all - :idling, :do => lambda {}

        event :park
          transition all => :parked
        end

        event :crash
          transition all - :parked => :stalled
        end
      end
    end

In the above example, `all` will match the following states since they are known:

- `parked`

- `stalled`

- `idling`

    # File lib/state_machine/matcher_helpers.rb, line 28
    def all
      AllMatcher.instance
    end

Also aliased as: any
any() click to toggle source
Alias for: all
same() click to toggle source

Represents a state that matches the original `from` state. This is useful for defining transitions which are loopbacks.

## Examples

    class Vehicle
      state_machine do
        event :ignite
          transition [:idling, :first_gear] => same
        end
      end
    end

In the above example, `same` will match whichever the from state is. In the case of the `ignite` event, it is essential the same as the following:

    transition :parked => :parked, :first_gear => :first_gear

    # File lib/state_machine/matcher_helpers.rb, line 50
    def same
      LoopbackMatcher.instance
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.