Sha256: 05b6441ebed3c49007eac0f7c48e024faaa682a6ecaabcf7f4aa4fb12d4afce2

Contents?: true

Size: 641 Bytes

Versions: 31

Compression:

Stored size: 641 Bytes

Contents

module MongoMapper
  module Associations
    class ManyDocumentsAsProxy < ManyDocumentsProxy
      protected
        def scoped_conditions
          {as_type_name => @owner.class.name, as_id_name => @owner.id}
        end

        def apply_scope(doc)
          ensure_owner_saved

          doc.send("#{as_type_name}=", @owner.class.name)
          doc.send("#{as_id_name}=", @owner.id)

          doc
        end

        def as_type_name
          @as_type_name ||= @association.options[:as].to_s + "_type"
        end

        def as_id_name
          @as_id_name ||= @association.options[:as].to_s + "_id"
        end
    end
  end
end

Version data entries

31 entries across 31 versions & 6 rubygems

Version Path
crnixon-mongomapper-0.3.4 lib/mongomapper/associations/many_documents_as_proxy.rb
djsun-mongomapper-0.3.5.1 lib/mongomapper/associations/many_documents_as_proxy.rb
djsun-mongomapper-0.3.5.2 lib/mongomapper/associations/many_documents_as_proxy.rb
djsun-mongomapper-0.3.5.4 lib/mongomapper/associations/many_documents_as_proxy.rb
djsun-mongomapper-0.3.5.5 lib/mongomapper/associations/many_documents_as_proxy.rb
djsun-mongomapper-0.3.5 lib/mongomapper/associations/many_documents_as_proxy.rb
jnunemaker-mongomapper-0.3.4 lib/mongomapper/associations/many_documents_as_proxy.rb
jnunemaker-mongomapper-0.3.5 lib/mongomapper/associations/many_documents_as_proxy.rb
djsun-mongo_mapper-0.5.6.6 lib/mongo_mapper/associations/many_documents_as_proxy.rb
djsun-mongo_mapper-0.5.6.5 lib/mongo_mapper/associations/many_documents_as_proxy.rb
djsun-mongo_mapper-0.5.6.4 lib/mongo_mapper/associations/many_documents_as_proxy.rb
djsun-mongo_mapper-0.5.6.3 lib/mongo_mapper/associations/many_documents_as_proxy.rb
djsun-mongo_mapper-0.5.6.2 lib/mongo_mapper/associations/many_documents_as_proxy.rb
djsun-mongo_mapper-0.5.6.1 lib/mongo_mapper/associations/many_documents_as_proxy.rb
mongo_mapper-0.5.6 lib/mongo_mapper/associations/many_documents_as_proxy.rb
djsun-mongo_mapper-0.5.5.3 lib/mongo_mapper/associations/many_documents_as_proxy.rb
mongo_mapper-unstable-2009.10.16 lib/mongo_mapper/associations/many_documents_as_proxy.rb
djsun-mongo_mapper-0.5.5.2 lib/mongo_mapper/associations/many_documents_as_proxy.rb
mongo_mapper-0.5.5 lib/mongo_mapper/associations/many_documents_as_proxy.rb
mongo_mapper-unstable-2009.10.12 lib/mongo_mapper/associations/many_documents_as_proxy.rb