module Skr::Concerns::StateMachine::ClassMethods
Public Instance Methods
state_machine(options={}, &block )
click to toggle source
Mark class as a StateMachine
{github.com/aasm/aasm}
Specifically it:
* Adds the methods in {InstanceMethods} to the class * Blacklists the "state" field so it cannot be set via the API * Allows access to the "state_event" pseudo field from the API * Sets up the aasm library with the contents of &block
# File lib/skr/concerns/state_machine.rb, line 23 def state_machine(options={}, &block ) include InstanceMethods include AASM attr_accessor :state_event whitelist_attributes :state_event default_options={ no_direct_assignment: true, column: 'state', enum: true } aasm(default_options.merge(options), &block) whitelist_attributes :state_event export_methods :valid_state_events, :optional=>false blacklist_attributes :state before_save :fire_state_machine_event_on_save end