Sha256: 1a12a2e26a078299a4a5d1065c4ceb0bc7d8294420f7360428fc8b2e61766370

Contents?: true

Size: 817 Bytes

Versions: 60

Compression:

Stored size: 817 Bytes

Contents

# encoding: UTF-8
module MongoMapper
  module Plugins
    module Sci
      module ClassMethods
        def inherited(subclass)
          key :_type, String unless key?(:_type)
          subclass.instance_variable_set("@single_collection_inherited", true)
          subclass.set_collection_name(collection_name) unless subclass.embeddable?
          super
        end

        def single_collection_inherited?
          @single_collection_inherited == true
        end

        def query(options={})
          super.tap do |query|
            query[:_type] = name if single_collection_inherited?
          end
        end
      end

      module InstanceMethods
        def initialize(*args)
          super
          write_key :_type, self.class.name if self.class.key?(:_type)
        end
      end
    end
  end
end

Version data entries

60 entries across 60 versions & 7 rubygems

Version Path
jonbell-mongo_mapper-0.8.6 lib/mongo_mapper/plugins/sci.rb
ign-mongo_mapper-0.8.6.2 lib/mongo_mapper/plugins/sci.rb
ign-mongo_mapper-0.8.6.1 lib/mongo_mapper/plugins/sci.rb
ssherman-mongo_mapper-0.8.6 lib/mongo_mapper/plugins/sci.rb
mongo_mapper-0.8.6 lib/mongo_mapper/plugins/sci.rb
mongo_mapper-0.8.5 lib/mongo_mapper/plugins/sci.rb
honkster-mongo_mapper-0.8.4 lib/mongo_mapper/plugins/sci.rb
mongo_mapper-0.8.4 lib/mongo_mapper/plugins/sci.rb
mongo_mapper-unstable-2010.08.19 lib/mongo_mapper/plugins/sci.rb
mongo_mapper-unstable-2010.08.18 lib/mongo_mapper/plugins/sci.rb
mongo_mapper-unstable-2010.08.17 lib/mongo_mapper/plugins/sci.rb
mongo_mapper-unstable-2010.08.16 lib/mongo_mapper/plugins/sci.rb
mongo_mapper-unstable-2010.08.15 lib/mongo_mapper/plugins/sci.rb
mongo_mapper-unstable-2010.08.14 lib/mongo_mapper/plugins/sci.rb
mongo_mapper-unstable-2010.08.13 lib/mongo_mapper/plugins/sci.rb
mongo_mapper-unstable-2010.08.12 lib/mongo_mapper/plugins/sci.rb
mongo_mapper-unstable-2010.08.11 lib/mongo_mapper/plugins/sci.rb
mongo_mapper-unstable-2010.08.10 lib/mongo_mapper/plugins/sci.rb
mongo_mapper-unstable-2010.08.09 lib/mongo_mapper/plugins/sci.rb
mongo_mapper-0.8.3 lib/mongo_mapper/plugins/sci.rb