### Home Classes Methods

### In Files

- lib/state_machine/integrations/active_model/observer.rb

### Methods

- #update_with_transition

### 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::Integrations::ActiveModel::Observer

Adds support for invoking callbacks on ActiveModel observers with more than one argument (e.g. the record and the state transition). By default, ActiveModel only supports passing the record into the callbacks.

For example:

    class VehicleObserver < ActiveModel::Observer
      # The default behavior: only pass in the record
      def after_save(vehicle)
      end

      # Custom behavior: allow the transition to be passed in as well
      def after_transition(vehicle, transition)
        Audit.log(vehicle, transition)
      end
    end

### Public Instance Methods

update_with_transition(observer_update) click to toggle source

    # File lib/state_machine/integrations/active_model/observer.rb, line 22
    def update_with_transition(observer_update)
      method = observer_update.method
      send(method, *observer_update.args) if respond_to?(method)
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.