module ActiveState::Model

Attributes

state[RW]

Public Class Methods

included(mod) click to toggle source
# File lib/active_state/model.rb, line 24
def self.included(mod)
  mod.extend ClassMethods
  mod.validates_with StateValidator
  mod.after_initialize :create_state_object
  mod.before_save :synchronize_state_column
end

Private Instance Methods

create_state_object() click to toggle source
# File lib/active_state/model.rb, line 33
def create_state_object
  state_class =
    if state_name.nil?
      self.class.initial_state
    else
      Object.const_get state_name
    end
  @state = state_class.new self
end
synchronize_state_column() click to toggle source
# File lib/active_state/model.rb, line 43
def synchronize_state_column
  self.state_name = state.class.name
end