Module: MongoMapper::Plugins::Sci::ClassMethods

Defined in:
lib/mongo_mapper/plugins/sci.rb

Instance Method Summary collapse

Instance Method Details

#inherited(subclass) ⇒ Object



6
7
8
9
10
11
# File 'lib/mongo_mapper/plugins/sci.rb', line 6

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

#query(options = {}) ⇒ Object



17
18
19
20
21
# File 'lib/mongo_mapper/plugins/sci.rb', line 17

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

#single_collection_inherited?Boolean

Returns:



13
14
15
# File 'lib/mongo_mapper/plugins/sci.rb', line 13

def single_collection_inherited?
  @single_collection_inherited == true
end