class Polyamorous::Join
Attributes
klass[R]
name[RW]
type[R]
Public Class Methods
new(name, type = InnerJoin, klass = nil)
click to toggle source
# 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
Public Instance Methods
add_to_tree(hash)
click to toggle source
# File lib/polyamorous/join.rb, line 35 def add_to_tree(hash) hash[self] ||= {} end
eql?(other)
click to toggle source
# 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
Also aliased as: ==
hash()
click to toggle source
# File lib/polyamorous/join.rb, line 22 def hash [@name, @type, @klass].hash end
klass=(klass)
click to toggle source
# File lib/polyamorous/join.rb, line 14 def klass=(klass) @klass = convert_to_class(klass) if klass end
type=(type)
click to toggle source
# File lib/polyamorous/join.rb, line 18 def type=(type) @type = convert_to_arel_join_type(type) if type end
Private Instance Methods
convert_to_arel_join_type(type)
click to toggle source
# File lib/polyamorous/join.rb, line 41 def convert_to_arel_join_type(type) case type when 'inner', :inner InnerJoin when 'outer', :outer OuterJoin when Class if [InnerJoin, OuterJoin].include? type type else raise ArgumentError, "#{type} cannot be converted to an ARel join type" end else raise ArgumentError, "#{type} cannot be converted to an ARel join type" end end
convert_to_class(value)
click to toggle source
# File lib/polyamorous/join.rb, line 58 def convert_to_class(value) case value when String, Symbol Kernel.const_get(value) when Class value else raise ArgumentError, "#{value} cannot be converted to a Class" end end