Class: Squeel::Nodes::Join
Overview
A node representing a joined association
Instance Attribute Summary collapse
-
#_join ⇒ Object
readonly
Returns the value of attribute _join.
Instance Method Summary collapse
- #add_to_tree(hash) ⇒ Object
-
#eql?(other) ⇒ Boolean
(also: #==)
Compare with other objects.
-
#hash ⇒ Object
Implemented for equality testing.
-
#initialize(name, type = 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.
Methods inherited from Node
Constructor Details
#initialize(name, type = InnerJoin, klass = nil) ⇒ Join
Create a new Join node
17 18 19 |
# File 'lib/squeel/nodes/join.rb', line 17 def initialize(name, type = 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
61 62 63 64 65 66 67 68 |
# File 'lib/squeel/nodes/join.rb', line 61 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, InnerJoin, args[0])]) else KeyPath.new([self, method_id]) end end |
Instance Attribute Details
#_join ⇒ Object (readonly)
Returns the value of attribute _join.
9 10 11 |
# File 'lib/squeel/nodes/join.rb', line 9 def _join @_join end |
Instance Method Details
#add_to_tree(hash) ⇒ Object
86 87 88 |
# File 'lib/squeel/nodes/join.rb', line 86 def add_to_tree(hash) hash[_join] ||= {} end |
#eql?(other) ⇒ Boolean Also known as: ==
Compare with other objects
45 46 47 48 49 50 |
# File 'lib/squeel/nodes/join.rb', line 45 def eql?(other) self.class.eql?(other.class) && self._name.eql?(other._name) && self._type.eql?(other._type) && self._klass.eql?(other._klass) end |
#hash ⇒ Object
Implemented for equality testing
40 41 42 |
# File 'lib/squeel/nodes/join.rb', line 40 def hash [_name, _type, _klass].hash end |
#inner ⇒ Join
Set the join type to an inner join
23 24 25 26 |
# File 'lib/squeel/nodes/join.rb', line 23 def inner self._type = InnerJoin self end |
#outer ⇒ Join
Set the join type to an outer join
30 31 32 33 |
# File 'lib/squeel/nodes/join.rb', line 30 def outer self._type = OuterJoin self end |
#polymorphic? ⇒ Boolean
35 36 37 |
# File 'lib/squeel/nodes/join.rb', line 35 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.
82 83 84 |
# File 'lib/squeel/nodes/join.rb', line 82 def to_sym nil end |
#~ ⇒ KeyPath
Return a KeyPath containing only this Join, but flagged as absolute. This helps Joins behave more like a KeyPath, as anyone using the Squeel DSL is likely to think of them as such.
74 75 76 |
# File 'lib/squeel/nodes/join.rb', line 74 def ~ KeyPath.new [self], true end |