class Mongoid::Relations::Referenced::Many
Private Instance Methods
calc_new_collection_name(query_class)
click to toggle source
# File lib/mongoid/collection_separated/monkey_patches.rb, line 103 def calc_new_collection_name query_class collection_name_for query_class, base.send(query_class.separated_parent_field) end
criteria_with_separated()
click to toggle source
Changes:
-
'base' should be an instance of Form
-
If form has entries_separated flat and collection name is entries, clone a new context because it is build each time when called and set to context. Then remove form_id from selector because all the entries inside the new collection has the same form_id
# File lib/mongoid/collection_separated/monkey_patches.rb, line 77 def criteria_with_separated cri = criteria_without_separated query_class = cri.instance_variable_get :@klass if should_query_from_separated_collection? query_class context = cri.context.clone new_collection_name = calc_new_collection_name query_class unless new_collection_name.blank? context.collection.instance_variable_set :@name, new_collection_name cri.instance_variable_set :'@collection', @collection end end cri end
Also aliased as: criteria
is_separated_parent_class?(query_class)
click to toggle source
# File lib/mongoid/collection_separated/monkey_patches.rb, line 99 def is_separated_parent_class? query_class base.is_a?(query_class.separated_parent_class) && base.respond_to?(query_class.separated_parent_field) end
is_separated_query_class?(query_class)
click to toggle source
# File lib/mongoid/collection_separated/monkey_patches.rb, line 95 def is_separated_query_class? query_class query_class.respond_to?(:separated_field) && query_class.send(:separated_field) && query_class.respond_to?(:calc_collection_name_fun) && query_class.respond_to?(query_class.calc_collection_name_fun) end
should_query_from_separated_collection?(query_class)
click to toggle source
# File lib/mongoid/collection_separated/monkey_patches.rb, line 91 def should_query_from_separated_collection?(query_class) is_separated_query_class?(query_class) && is_separated_parent_class?(query_class) end