Class: ParamsReady::Query::JoinStatement

Inherits:
Object
  • Object
show all
Defined in:
lib/params_ready/query/join_clause.rb

Defined Under Namespace

Classes: Builder

Instance Method Summary collapse

Constructor Details

#initialize(conditions) ⇒ JoinStatement

Returns a new instance of JoinStatement.

Raises:



93
94
95
96
97
98
# File 'lib/params_ready/query/join_clause.rb', line 93

def initialize(conditions)
  @conditions = conditions.freeze
  raise ParamsReadyError, "Join clause is empty" if @conditions.empty?

  freeze
end

Instance Method Details

#to_arel(base_table, join_table, context, parameter) ⇒ Object



100
101
102
103
104
105
106
107
# File 'lib/params_ready/query/join_clause.rb', line 100

def to_arel(base_table, join_table, context, parameter)
  @conditions.reduce(nil) do |result, condition|
    arel = condition.to_arel(base_table, join_table, context, parameter)
    next arel if result.nil?

    result.and(arel)
  end
end