Class: Squeel::Nodes::Join

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, type = Arel::InnerJoin, klass = nil) ⇒ Join

Returns a new instance of Join.



6
7
8
9
# File 'lib/squeel/nodes/join.rb', line 6

def initialize(name, type = Arel::InnerJoin, klass = nil)
  @name, @type = name, type
  @klass = convert_to_class(klass) if klass
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_id, *args) ⇒ Object



38
39
40
41
42
43
44
45
# File 'lib/squeel/nodes/join.rb', line 38

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

#klassObject

Returns the value of attribute klass.



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

def klass
  @klass
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#typeObject (readonly)

Returns the value of attribute type.



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

def type
  @type
end

Instance Method Details

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

Returns:

  • (Boolean)


29
30
31
32
33
34
# File 'lib/squeel/nodes/join.rb', line 29

def eql?(other)
  self.class == other.class &&
  self.name  == other.name &&
  self.type == other.type &&
  self.klass == other.klass
end

#innerObject



11
12
13
14
# File 'lib/squeel/nodes/join.rb', line 11

def inner
  @type = Arel::InnerJoin
  self
end

#outerObject



16
17
18
19
# File 'lib/squeel/nodes/join.rb', line 16

def outer
  @type = Arel::OuterJoin
  self
end

#polymorphic?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/squeel/nodes/join.rb', line 25

def polymorphic?
  @klass
end

#to_symObject

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.



50
51
52
# File 'lib/squeel/nodes/join.rb', line 50

def to_sym
  nil
end