Class: Squeel::Nodes::SubqueryJoin

Inherits:
Node
  • Object
show all
Defined in:
lib/squeel/nodes/subquery_join.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Node

#each, #grep

Constructor Details

#initialize(subquery, constraints, type = Squeel::InnerJoin) ⇒ SubqueryJoin

Returns a new instance of SubqueryJoin

Raises:

  • (ArgumentError)


6
7
8
9
10
11
12
13
14
15
16
# File 'lib/squeel/nodes/subquery_join.rb', line 6

def initialize(subquery, constraints, type = Squeel::InnerJoin)
  raise ArgumentError,
    "subquery(#{subquery}) isn't an Squeel::Nodes::As" unless subquery.is_a?(As)

  raise ArgumentError,
    "constraints(#{constraints}) isn't a Squeel::Nodes::Node" unless constraints.is_a?(Node)

  self.subquery = subquery
  self.constraints = constraints
  self.type = type
end

Instance Attribute Details

#constraintsObject

Returns the value of attribute constraints



4
5
6
# File 'lib/squeel/nodes/subquery_join.rb', line 4

def constraints
  @constraints
end

#subqueryObject

Returns the value of attribute subquery



4
5
6
# File 'lib/squeel/nodes/subquery_join.rb', line 4

def subquery
  @subquery
end

#typeObject

Returns the value of attribute type



4
5
6
# File 'lib/squeel/nodes/subquery_join.rb', line 4

def type
  @type
end

Instance Method Details

#eql?(other) ⇒ Boolean Also known as: ==

Compare with other objects

Returns:

  • (Boolean)


34
35
36
37
38
39
# File 'lib/squeel/nodes/subquery_join.rb', line 34

def eql?(other)
  self.class.eql?(other.class) &&
  self.subquery.eql?(other.subquery) &&
  self.type.eql?(other.type) &&
  self.constraints.eql?(other.constraints)
end

#hashObject

Implemented for equality testing



19
20
21
# File 'lib/squeel/nodes/subquery_join.rb', line 19

def hash
  [subquery, type, constraints].hash
end

#innerObject



23
24
25
26
# File 'lib/squeel/nodes/subquery_join.rb', line 23

def inner
  self.type = Squeel::InnerJoin
  self
end

#outerObject



28
29
30
31
# File 'lib/squeel/nodes/subquery_join.rb', line 28

def outer
  self.type = Squeel::OuterJoin
  self
end