2008-02-22 20:46:31 +00:00
|
|
|
module AASM
|
|
|
|
module Persistence
|
2008-04-29 05:27:56 +00:00
|
|
|
|
|
|
|
# Checks to see this class or any of it's superclasses inherit from
|
|
|
|
# ActiveRecord::Base and if so includes ActiveRecordPersistence
|
2008-02-22 20:46:31 +00:00
|
|
|
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)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|