class MongoModel::Associations::HasManyByIds::Proxy
Constants
- OVERRIDE_METHODS
Pass these methods to the association class rather than the Array target
Public Instance Methods
<<(doc)
click to toggle source
Calls superclass method
# File lib/mongomodel/concerns/associations/has_many_by_ids.rb, line 117 def <<(doc) ensure_class(doc) super if loaded? ids << doc.id self end
[]=(index, doc)
click to toggle source
Calls superclass method
# File lib/mongomodel/concerns/associations/has_many_by_ids.rb, line 110 def []=(index, doc) ensure_class(doc) super if loaded? ids[index] = doc.id self end
build(*args, &block)
click to toggle source
# File lib/mongomodel/concerns/associations/has_many_by_ids.rb, line 98 def build(*args, &block) doc = association.build(*args, &block) self << doc doc end
clear()
click to toggle source
Calls superclass method
# File lib/mongomodel/concerns/associations/has_many_by_ids.rb, line 159 def clear super if loaded? ids.clear self end
concat(documents)
click to toggle source
Calls superclass method
# File lib/mongomodel/concerns/associations/has_many_by_ids.rb, line 124 def concat(documents) ensure_class(documents) super if loaded? ids.concat(documents.map { |doc| doc.id }) self end
create(*args, &block)
click to toggle source
# File lib/mongomodel/concerns/associations/has_many_by_ids.rb, line 104 def create(*args, &block) doc = association.create(*args, &block) self << doc doc end
delete(doc)
click to toggle source
Calls superclass method
# File lib/mongomodel/concerns/associations/has_many_by_ids.rb, line 165 def delete(doc) super if loaded? ids.delete(doc.id) self end
delete_at(index)
click to toggle source
Calls superclass method
# File lib/mongomodel/concerns/associations/has_many_by_ids.rb, line 171 def delete_at(index) super if loaded? ids.delete_at(index) self end
delete_if(&block)
click to toggle source
Calls superclass method
# File lib/mongomodel/concerns/associations/has_many_by_ids.rb, line 177 def delete_if(&block) super ids.replace(map { |doc| doc.id }) self end
ids()
click to toggle source
# File lib/mongomodel/concerns/associations/has_many_by_ids.rb, line 183 def ids association.ids end
insert(index, doc)
click to toggle source
Calls superclass method
# File lib/mongomodel/concerns/associations/has_many_by_ids.rb, line 131 def insert(index, doc) ensure_class(doc) super if loaded? ids.insert(index, doc.id) self end
push(*documents)
click to toggle source
Calls superclass method
# File lib/mongomodel/concerns/associations/has_many_by_ids.rb, line 145 def push(*documents) ensure_class(documents) super if loaded? ids.push(*documents.map { |doc| doc.id }) self end
replace(documents)
click to toggle source
Calls superclass method
# File lib/mongomodel/concerns/associations/has_many_by_ids.rb, line 138 def replace(documents) ensure_class(documents) super if loaded? ids.replace(documents.map { |doc| doc.id }) self end
unshift(*documents)
click to toggle source
Calls superclass method
# File lib/mongomodel/concerns/associations/has_many_by_ids.rb, line 152 def unshift(*documents) ensure_class(documents) super if loaded? ids.unshift(*documents.map { |doc| doc.id }) self end
Private Instance Methods
method_missing(method_id, *args, &block)
click to toggle source
Calls superclass method
MongoModel::Associations::Base::Proxy#method_missing
# File lib/mongomodel/concerns/associations/has_many_by_ids.rb, line 188 def method_missing(method_id, *args, &block) if target.respond_to?(method_id) && !OVERRIDE_METHODS.include?(method_id.to_sym) super(method_id, *args, &block) else association.scoped.send(method_id, *args, &block) end end