Module: AASM::Persistence

Defined in:
lib/aasm/persistence.rb,
lib/aasm/persistence/orm.rb,
lib/aasm/persistence/base.rb,
lib/aasm/persistence/plain_persistence.rb,
lib/aasm/persistence/redis_persistence.rb,
lib/aasm/persistence/sequel_persistence.rb,
lib/aasm/persistence/mongoid_persistence.rb,
lib/aasm/persistence/dynamoid_persistence.rb,
lib/aasm/persistence/no_brainer_persistence.rb,
lib/aasm/persistence/active_record_persistence.rb,
lib/aasm/persistence/core_data_query_persistence.rb

Defined Under Namespace

Modules: ActiveRecordPersistence, Base, CoreDataQueryPersistence, DynamoidPersistence, MongoidPersistence, NoBrainerPersistence, ORM, PlainPersistence, RedisPersistence, SequelPersistence

Class Method Summary collapse

Class Method Details

.load_persistence(base) ⇒ Object


5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/aasm/persistence.rb', line 5

def load_persistence(base)
  # Use a fancier auto-loading thingy, perhaps.  When there are more persistence engines.
  hierarchy = base.ancestors.map {|klass| klass.to_s}

  if hierarchy.include?("ActiveRecord::Base")
    require_persistence :active_record
    include_persistence base, :active_record
  elsif hierarchy.include?("Mongoid::Document")
    require_persistence :mongoid
    include_persistence base, :mongoid
  elsif hierarchy.include?("NoBrainer::Document")
    require_persistence :no_brainer
    include_persistence base, :no_brainer
  elsif hierarchy.include?("Sequel::Model")
    require_persistence :sequel
    include_persistence base, :sequel
  elsif hierarchy.include?("Dynamoid::Document")
    require_persistence :dynamoid
    include_persistence base, :dynamoid
  elsif hierarchy.include?("Redis::Objects")
    require_persistence :redis
    include_persistence base, :redis
  elsif hierarchy.include?("CDQManagedObject")
    include_persistence base, :core_data_query
  else
    include_persistence base, :plain
  end
end