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

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

Instance Method Summary collapse

Instance Method Details

#inherited(subclass) ⇒ Object



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

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



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

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

#single_collection_inherited?Boolean

Returns:



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

def single_collection_inherited?
  @single_collection_inherited == true
end