Class: Polyamorous::Join

Inherits:
Object
  • Object
show all
Includes:
TreeNode
Defined in:
lib/polyamorous/join.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Join.



8
9
10
11
12
# File 'lib/polyamorous/join.rb', line 8

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

Instance Attribute Details

#klassObject

Returns the value of attribute klass.



6
7
8
# File 'lib/polyamorous/join.rb', line 6

def klass
  @klass
end

#nameObject

Returns the value of attribute name.



5
6
7
# File 'lib/polyamorous/join.rb', line 5

def name
  @name
end

#typeObject

Returns the value of attribute type.



6
7
8
# File 'lib/polyamorous/join.rb', line 6

def type
  @type
end

Instance Method Details

#add_to_tree(hash) ⇒ Object



35
36
37
# File 'lib/polyamorous/join.rb', line 35

def add_to_tree(hash)
  hash[self] ||= {}
end

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

Returns:

  • (Boolean)


26
27
28
29
30
31
# File 'lib/polyamorous/join.rb', line 26

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

#hashObject



22
23
24
# File 'lib/polyamorous/join.rb', line 22

def hash
  [@name, @type, @klass].hash
end