Module: StateShifter::Definition

Defined in:
lib/state_shifter/definition.rb,
lib/state_shifter/definition/contents.rb,
lib/state_shifter/definition/class_methods.rb,
lib/state_shifter/definition/instance_methods.rb,
lib/state_shifter/definition/active_record_integration_methods.rb

Defined Under Namespace

Modules: ActiveRecordIntegrationMethods, ClassMethods, InstanceMethods Classes: Contents, StatePersistenceAttributeNotPresent

Class Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/state_shifter/definition.rb', line 4

def self.included klass
  klass.send :include, InstanceMethods
  klass.extend ClassMethods

  if Object.const_defined?(:ActiveRecord)
    if klass < ActiveRecord::Base
      klass.send :include, ActiveRecordIntegrationMethods
      klass.send :_include_state_scopes=, true
      klass.before_validation :write_initial_state
    end
  end
end