Module: Mongoid::Clients::Options
- Defined in:
- lib/mongoid/collection_separatable/monkey_patches.rb
Instance Method Summary collapse
- #collection_name_with_separated ⇒ Object (also: #collection_name)
- #collection_with_separated(parent = nil) ⇒ Object (also: #collection)
- #separated_collection_name(klass) ⇒ Object
Instance Method Details
#collection_name_with_separated ⇒ Object Also known as: collection_name
110 111 112 113 114 115 |
# File 'lib/mongoid/collection_separatable/monkey_patches.rb', line 110 def collection_name_with_separated klass = self.class origin_collection_name = collection_name_without_separated return origin_collection_name unless self.class.respond_to?(:separated_field) separated_collection_name klass end |
#collection_with_separated(parent = nil) ⇒ Object Also known as: collection
99 100 101 102 103 104 105 |
# File 'lib/mongoid/collection_separatable/monkey_patches.rb', line 99 def collection_with_separated(parent = nil) klass = self.class origin_collection = collection_without_separated(parent) return origin_collection unless self.class.respond_to?(:separated_field) origin_collection.instance_variable_set :@name, separated_collection_name(klass) origin_collection end |
#separated_collection_name(klass) ⇒ Object
120 121 122 |
# File 'lib/mongoid/collection_separatable/monkey_patches.rb', line 120 def separated_collection_name(klass) klass.where(klass.separated_field => self.send(klass.separated_field)).ensured_collection.name end |