Class: BabySqueel::Relation
Direct Known Subclasses
Instance Attribute Summary collapse
-
#_scope ⇒ Object
Returns the value of attribute _scope.
Attributes inherited from Table
Instance Method Summary collapse
-
#association(name) ⇒ Object
Constructs a new BabySqueel::Association.
-
#initialize(scope) ⇒ Relation
constructor
A new instance of Relation.
-
#sift(sifter_name, *args) ⇒ Object
Invokes a sifter defined on the model.
Methods inherited from Table
#[], #_arel, #alias, #alias!, #alias?, #as, #evaluate, #find_alias, #inner, #inner!, #on, #on!, #outer, #outer!
Constructor Details
#initialize(scope) ⇒ Relation
Returns a new instance of Relation.
7 8 9 10 |
# File 'lib/baby_squeel/relation.rb', line 7 def initialize(scope) super(scope.arel_table) @_scope = scope end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class BabySqueel::Table
Instance Attribute Details
#_scope ⇒ Object
Returns the value of attribute _scope.
5 6 7 |
# File 'lib/baby_squeel/relation.rb', line 5 def _scope @_scope end |
Instance Method Details
#association(name) ⇒ Object
Constructs a new BabySqueel::Association. Raises an exception if the association is not found.
14 15 16 17 18 19 20 |
# File 'lib/baby_squeel/relation.rb', line 14 def association(name) if reflection = _scope.reflect_on_association(name) Association.new(self, reflection) else raise AssociationNotFoundError.new(_scope.model_name, name) end end |