Class: Squeel::Nodes::Join
- Inherits:
-
Object
- Object
- Squeel::Nodes::Join
- Defined in:
- lib/squeel/nodes/join.rb
Overview
A node representing a joined association
Instance Attribute Summary collapse
-
#_join ⇒ Object
readonly
Returns the value of attribute _join.
Instance Method Summary collapse
-
#eql?(other) ⇒ Boolean
(also: #==)
Compare with other objects.
-
#initialize(name, type = Arel::InnerJoin, klass = nil) ⇒ Join
constructor
Create a new Join node.
-
#inner ⇒ Join
Set the join type to an inner join.
-
#method_missing(method_id, *args) ⇒ Object
Ensures that a Join can be used as the base of a new KeyPath.
-
#outer ⇒ Join
Set the join type to an outer join.
- #polymorphic? ⇒ Boolean
-
#to_sym ⇒ NilClass
expand_hash_conditions_for_aggregates assumes our hash keys can be converted to symbols, so this has to be implemented, but it doesn’t really have to do anything useful.
-
#~ ⇒ KeyPath
Return a KeyPath containing only this Join, but flagged as absolute.
Constructor Details
#initialize(name, type = Arel::InnerJoin, klass = nil) ⇒ Join
Create a new Join node
15 16 17 |
# File 'lib/squeel/nodes/join.rb', line 15 def initialize(name, type = Arel::InnerJoin, klass = nil) @_join = Polyamorous::Join.new(name, type, klass) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#node_name ⇒ KeyPath #node_name(klass) ⇒ KeyPath
Ensures that a Join can be used as the base of a new KeyPath
54 55 56 57 58 59 60 61 |
# File 'lib/squeel/nodes/join.rb', line 54 def method_missing(method_id, *args) super if method_id == :to_ary if (args.size == 1) && (Class === args[0]) KeyPath.new(self, Join.new(method_id, Arel::InnerJoin, args[0])) else KeyPath.new(self, method_id) end end |
Instance Attribute Details
#_join ⇒ Object (readonly)
Returns the value of attribute _join.
7 8 9 |
# File 'lib/squeel/nodes/join.rb', line 7 def _join @_join end |
Instance Method Details
#eql?(other) ⇒ Boolean Also known as: ==
Compare with other objects
38 39 40 41 42 43 |
# File 'lib/squeel/nodes/join.rb', line 38 def eql?(other) self.class.eql?(other.class) && self._name.eql?(other._name) && self._type.eql?(other._type) && self._klass.eql?(other._klass) end |
#inner ⇒ Join
Set the join type to an inner join
21 22 23 24 |
# File 'lib/squeel/nodes/join.rb', line 21 def inner self._type = Arel::InnerJoin self end |
#outer ⇒ Join
Set the join type to an outer join
28 29 30 31 |
# File 'lib/squeel/nodes/join.rb', line 28 def outer self._type = Arel::OuterJoin self end |
#polymorphic? ⇒ Boolean
33 34 35 |
# File 'lib/squeel/nodes/join.rb', line 33 def polymorphic? _klass end |
#to_sym ⇒ NilClass
expand_hash_conditions_for_aggregates assumes our hash keys can be converted to symbols, so this has to be implemented, but it doesn’t really have to do anything useful.
75 76 77 |
# File 'lib/squeel/nodes/join.rb', line 75 def to_sym nil end |