class Elastictastic::ChildCollectionProxy
Attributes
parent[R]
Public Class Methods
new(association, parent)
click to toggle source
Calls superclass method
# File lib/elastictastic/child_collection_proxy.rb, line 5 def initialize(association, parent) super( parent.index, association.clazz, Search.new( 'query' => { 'constant_score' => { 'filter' => { 'term' => { '_parent' => parent.id }} } } ), self ) @parent = parent @transient_children = [] end
Public Instance Methods
<<(child)
click to toggle source
# File lib/elastictastic/child_collection_proxy.rb, line 40 def <<(child) child.parent = @parent @transient_children << child self end
each(&block)
click to toggle source
Calls superclass method
# File lib/elastictastic/child_collection_proxy.rb, line 31 def each(&block) if block super if @parent.persisted? transient_children.each(&block) else ::Enumerator.new(self, :each) end end
first()
click to toggle source
Calls superclass method
# File lib/elastictastic/child_collection_proxy.rb, line 27 def first super || transient_children.first end
initialize_instance(instance)
click to toggle source
Calls superclass method
# File lib/elastictastic/child_collection_proxy.rb, line 22 def initialize_instance(instance) super self << instance end
transient_children()
click to toggle source
# File lib/elastictastic/child_collection_proxy.rb, line 46 def transient_children @transient_children.tap do |children| children.reject! do |child| !child.transient? end end end
Private Instance Methods
params_for_find()
click to toggle source
Calls superclass method
# File lib/elastictastic/child_collection_proxy.rb, line 56 def params_for_find super.merge('routing' => @parent.id) end