class ParamsReady::Query::Join
Attributes
arel_table[R]
statement[R]
type[R]
Public Class Methods
new(table, type, &block)
click to toggle source
# File lib/params_ready/query/join_clause.rb, line 8 def initialize(table, type, &block) @arel_table = table @type = arel_type(type) @statement = JoinStatement.new(&block) end
Public Instance Methods
arel_type(type)
click to toggle source
# File lib/params_ready/query/join_clause.rb, line 14 def arel_type(type) case type when :inner then Arel::Nodes::InnerJoin when :outer then Arel::Nodes::OuterJoin else raise ParamsReadyError, "Unimplemented join type '#{type}'" end end
to_arel(base_table, context, parameter)
click to toggle source
# File lib/params_ready/query/join_clause.rb, line 22 def to_arel(base_table, context, parameter) join_statement = @statement.to_arel(base_table, @arel_table, context, parameter) base_table.join(@arel_table, @type).on(join_statement) end