Skip to content

Commit

Permalink
shorten the persistence loading stuff a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
alto committed Apr 24, 2013
1 parent 55f6ccd commit 7ab505a
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/aasm/persistence.rb
Expand Up @@ -7,20 +7,20 @@ def load_persistence(base)
hierarchy = base.ancestors.map {|klass| klass.to_s}

if hierarchy.include?("ActiveRecord::Base")
require_files_for('active_record_persistence')
require_files_for(:active_record)
base.send(:include, AASM::Persistence::ActiveRecordPersistence)
elsif hierarchy.include?("Mongoid::Document")
require_files_for('mongoid_persistence')
require_files_for(:mongoid)
base.send(:include, AASM::Persistence::MongoidPersistence)
end
end

private

def require_files_for(persistence)
require File.join(File.dirname(__FILE__), 'persistence', 'base')
require File.join(File.dirname(__FILE__), 'persistence', 'read_state')
require File.join(File.dirname(__FILE__), 'persistence', persistence)
['base', 'read_state', "#{persistence}_persistence"].each do |file_name|
require File.join(File.dirname(__FILE__), 'persistence', file_name)
end
end

end # class << self
Expand Down

0 comments on commit 7ab505a

Please sign in to comment.