Method: Sequel::Model::Associations::AssociationReflection#apply_ruby_eager_limit_strategy

Defined in:
lib/sequel/model/associations.rb

#apply_ruby_eager_limit_strategy(rows, limit_and_offset = limit_and_offset()) ⇒ Object

If the ruby eager limit strategy is being used, slice the array using the slice range to return the object(s) at the correct offset/limit.



165
166
167
168
169
170
171
172
173
174
# File 'lib/sequel/model/associations.rb', line 165

def apply_ruby_eager_limit_strategy(rows, limit_and_offset = limit_and_offset())
  name = self[:name]
  return unless range = slice_range(limit_and_offset)
  if returns_array?
    rows.each{|o| o.associations[name] = o.associations[name][range] || []}
  else
    offset = range.begin
    rows.each{|o| o.associations[name] = o.associations[name][offset]}
  end
end