Sha256: 0258aa109f8551b1b5747b9cacf184ef1767bb287aa234784553f0789b9b34b6

Contents?: true

Size: 859 Bytes

Versions: 12

Compression:

Stored size: 859 Bytes

Contents

module AASM
  module Persistence
    class << self

      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_files_for(:active_record)
          base.send(:include, AASM::Persistence::ActiveRecordPersistence)
        elsif hierarchy.include?("Mongoid::Document")
          require_files_for(:mongoid)
          base.send(:include, AASM::Persistence::MongoidPersistence)
        end
      end

    private

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

    end # class << self
  end
end # AASM

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
aasm-3.1.1 lib/aasm/persistence.rb
aasm-3.1.0 lib/aasm/persistence.rb
aasm-3.0.26 lib/aasm/persistence.rb
aasm-3.0.25 lib/aasm/persistence.rb
aasm-3.0.24 lib/aasm/persistence.rb
aasm-3.0.23 lib/aasm/persistence.rb
aasm-3.0.22 lib/aasm/persistence.rb
aasm-3.0.21 lib/aasm/persistence.rb
aasm-3.0.20 lib/aasm/persistence.rb
aasm-3.0.19 lib/aasm/persistence.rb
aasm-3.0.18 lib/aasm/persistence.rb
aasm-3.0.17 lib/aasm/persistence.rb