Module: AASM::Persistence
- Defined in:
- lib/aasm/persistence.rb,
lib/aasm/persistence/mongoid_persistence.rb,
lib/aasm/persistence/mongo_mapper_persistence.rb,
lib/aasm/persistence/active_record_persistence.rb
Defined Under Namespace
Modules: ActiveRecordPersistence, MongoMapperPersistence, MongoidPersistence
Class Method Summary collapse
-
.set_persistence(base) ⇒ Object
Checks to see this class or any of it’s superclasses inherit from ActiveRecord::Base and if so includes ActiveRecordPersistence.
Class Method Details
.set_persistence(base) ⇒ Object
Checks to see this class or any of it’s superclasses inherit from ActiveRecord::Base and if so includes ActiveRecordPersistence
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/aasm/persistence.rb', line 5 def self.set_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 File.join(File.dirname(__FILE__), 'persistence', 'active_record_persistence') base.send(:include, AASM::Persistence::ActiveRecordPersistence) elsif hierarchy.include?("Mongoid::Document") require File.join(File.dirname(__FILE__), 'persistence', 'mongoid_persistence') base.send(:include, AASM::Persistence::MongoidPersistence) elsif hierarchy.include?("MongoMapper::Document") require File.join(File.dirname(__FILE__), 'persistence', 'mongo_mapper_persistence') base.send(:include, AASM::Persistence::MongoMapperPersistence) end end |