Module: Sequel::Model::Associations::SingularAssociationReflection
- Included in:
- OneThroughOneAssociationReflection, OneToOneAssociationReflection, Plugins::ManyThroughMany::OneThroughManyAssociationReflection
- Defined in:
- lib/sequel/model/associations.rb
Overview
Methods that turn an association that returns multiple objects into an association that returns a single object.
Instance Method Summary collapse
-
#assign_singular? ⇒ Boolean
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.
-
#filter_by_associations_add_conditions? ⇒ Boolean
Add conditions when filtering by singular associations with orders, since the underlying relationship is probably not one-to-one.
-
#returns_array? ⇒ Boolean
Singular associations always return a single object, not an array.
Instance Method Details
#assign_singular? ⇒ Boolean
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.
758 759 760 |
# File 'lib/sequel/model/associations.rb', line 758 def assign_singular? super && (eager_limit_strategy != :ruby || !slice_range) end |
#filter_by_associations_add_conditions? ⇒ Boolean
Add conditions when filtering by singular associations with orders, since the underlying relationship is probably not one-to-one.
764 765 766 |
# File 'lib/sequel/model/associations.rb', line 764 def filter_by_associations_add_conditions? super || self[:order] end |
#returns_array? ⇒ Boolean
Singular associations always return a single object, not an array.
769 770 771 |
# File 'lib/sequel/model/associations.rb', line 769 def returns_array? false end |