class Rusql::Join

Constants

TYPES

Attributes

type[R]

Public Class Methods

new(type, table, condition) click to toggle source
# File lib/rusql/join.rb, line 13
def initialize(type, table, condition)
  final_table = table.is_a?(Table) ? table : ( table.respond_to?(:as_rusql_table) ? table.as_rusql_table : nil )

  raise Exception.new("Expected type to be one of #{ TYPES.map(&:to_s).join(",") }") unless TYPES.include?(type)
  raise TypeException.new(Table, table.class) if final_table.nil?
  raise TypeException.new(Condition, condition.class) unless condition.is_a?(Condition)

  @type = type
  @table = final_table
  @condition = condition
end

Public Instance Methods

to_s() click to toggle source
# File lib/rusql/join.rb, line 25
def to_s
  "#{ self.type.to_s.upcase.gsub("_"," ") } #{self.table.to_s_for_aliasing} ON #{self.condition.to_s(multiline: false) }"
end