Class/Module Index [+]

Quicksearch

Sequel::Model::Associations::SingularAssociationReflection

Methods that turn an association that returns multiple objects into an association that returns a single object.

Public Instance Methods

assign_singular?() click to toggle source

Singular associations do not assign singular if they are using the ruby eager limit strategy and have a slice range, since they need to store the array of associated objects in order to pick the correct one with an offset.

# File lib/sequel/model/associations.rb, line 1038
def assign_singular?
  super && (eager_limit_strategy != :ruby || !slice_range)
end
filter_by_associations_add_conditions?() click to toggle source

Add conditions when filtering by singular associations with orders, since the underlying relationship is probably not one-to-one.

# File lib/sequel/model/associations.rb, line 1044
def filter_by_associations_add_conditions?
  super || self[:order] || self[:eager_limit_strategy] || self[:filter_limit_strategy]
end
limit_and_offset() click to toggle source

Make sure singular associations always have 1 as the limit

# File lib/sequel/model/associations.rb, line 1049
def limit_and_offset
  r = super
  if r.first == 1
    r
  else
    [1, r[1]]
  end
end
returns_array?() click to toggle source

Singular associations always return a single object, not an array.

# File lib/sequel/model/associations.rb, line 1059
def returns_array?
  false
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.