module MarkMapper::Plugins::Sci::ClassMethods
Public Instance Methods
criteria_hash(criteria={})
click to toggle source
Calls superclass method
# File lib/mark_mapper/plugins/sci.rb, line 35 def criteria_hash(criteria={}) if single_collection_inherited? super criteria.merge(:_type => name) else super end end
explicit_collection_defined?()
click to toggle source
# File lib/mark_mapper/plugins/sci.rb, line 53 def explicit_collection_defined? @collection_defined == true end
inherited(subclass)
click to toggle source
Calls superclass method
# File lib/mark_mapper/plugins/sci.rb, line 12 def inherited(subclass) super if @collection_name == subclass.instance_variable_get("@collection_name") key :_type, String unless key?(:_type) subclass.single_collection_parent = self subclass.instance_variable_set("@single_collection_inherited", true) else remove_key :_type end end
query(options={})
click to toggle source
Calls superclass method
# File lib/mark_mapper/plugins/sci.rb, line 69 def query(options={}) super.tap do |query| query[:_type] = {'$eq' => [name] + descendants.map(&:name)} if single_collection_inherited? end end
set_collection_name(name)
click to toggle source
Calls superclass method
# File lib/mark_mapper/plugins/sci.rb, line 43 def set_collection_name(name) if single_collection_inherited? single_collection_parent.remove_key :_type single_collection_parent = nil @single_collection_inherited = false end @collection_defined = true super end
single_collection_inherited?()
click to toggle source
# File lib/mark_mapper/plugins/sci.rb, line 65 def single_collection_inherited? !!(@single_collection_inherited ||= false) end
single_collection_parent()
click to toggle source
# File lib/mark_mapper/plugins/sci.rb, line 57 def single_collection_parent @single_collection_parent end
single_collection_parent=(parent)
click to toggle source
# File lib/mark_mapper/plugins/sci.rb, line 61 def single_collection_parent=(parent) @single_collection_parent = parent end
single_collection_root()
click to toggle source
# File lib/mark_mapper/plugins/sci.rb, line 23 def single_collection_root parent = single_collection_parent || self root = parent while parent parent = parent.single_collection_parent root = parent unless parent.nil? end root end