Sha256: fe2bf7a62bf6ac148f5009058403314a6a18702b955e1a1b9ae3f2fa37331cad

Contents?: true

Size: 956 Bytes

Versions: 21

Compression:

Stored size: 956 Bytes

Contents

# encoding: UTF-8
module MongoMapper
  module Plugins
    module Rails
      class ActiveRecordAssociationAdapter
        attr_reader :klass, :macro, :name, :options

        def self.for_association(association)
          macro = case association
          when MongoMapper::Plugins::Associations::BelongsToAssociation
            :belongs_to
          when MongoMapper::Plugins::Associations::ManyAssociation
            :has_many
          when MongoMapper::Plugins::Associations::OneAssociation
            :has_one
          else
            raise "no #{name} for association of type #{association.class}"
          end

          new(association, macro)
        end

        def initialize(association, macro)
          @klass, @name = association.klass, association.name
          # only include compatible options
          @options = association.options.slice(:conditions, :order)

          @macro = macro
        end
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 3 rubygems

Version Path
mongo_mapper-0.17.0 lib/mongo_mapper/plugins/rails/active_record_association_adapter.rb
mongo_mapper-0.16.0 lib/mongo_mapper/plugins/rails/active_record_association_adapter.rb
mongo_mapper-0.15.6 lib/mongo_mapper/plugins/rails/active_record_association_adapter.rb
mongo_mapper-0.15.5 lib/mongo_mapper/plugins/rails/active_record_association_adapter.rb
mongo_mapper-0.15.4 lib/mongo_mapper/plugins/rails/active_record_association_adapter.rb
mongo_mapper-0.15.3 lib/mongo_mapper/plugins/rails/active_record_association_adapter.rb
mongo_mapper-0.15.2 lib/mongo_mapper/plugins/rails/active_record_association_adapter.rb
mongo_mapper-0.15.1 lib/mongo_mapper/plugins/rails/active_record_association_adapter.rb
mongo_mapper-0.15.0 lib/mongo_mapper/plugins/rails/active_record_association_adapter.rb
mongo_mapper-0.14.0 lib/mongo_mapper/plugins/rails/active_record_association_adapter.rb
mongo_mapper-0.14.0.rc1 lib/mongo_mapper/plugins/rails/active_record_association_adapter.rb
mongo_mapper-0.13.1 lib/mongo_mapper/plugins/rails/active_record_association_adapter.rb
mongo_mapper-0.13.0 lib/mongo_mapper/plugins/rails/active_record_association_adapter.rb
mongo_mapper-0.13.0.beta2 lib/mongo_mapper/plugins/rails/active_record_association_adapter.rb
mongo_mapper-0.13.0.beta1 lib/mongo_mapper/plugins/rails/active_record_association_adapter.rb
mongo_mapper-0.12.0 lib/mongo_mapper/plugins/rails/active_record_association_adapter.rb
lookout-mongo_mapper-0.11.3 lib/mongo_mapper/plugins/rails/active_record_association_adapter.rb
mongo_mapper-0.11.2 lib/mongo_mapper/plugins/rails/active_record_association_adapter.rb
jamieorc-mongo_mapper-0.11.1.1 lib/mongo_mapper/plugins/rails/active_record_association_adapter.rb
mongo_mapper-0.11.1 lib/mongo_mapper/plugins/rails/active_record_association_adapter.rb