Class: ParamsReady::Query::JoinCondition::Builder

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

Instance Method Summary collapse

Constructor Details

#initialize(expression, arel_table: nil) ⇒ Builder

Returns a new instance of Builder.



112
113
114
115
116
# File 'lib/params_ready/query/join_clause.rb', line 112

def initialize(expression, arel_table: nil)
  @on = Helpers::ArelBuilder::Attribute.instance(expression, arel_table: arel_table)
  @op = nil
  @to = nil
end

Instance Method Details

#buildObject



124
125
126
# File 'lib/params_ready/query/join_clause.rb', line 124

def build
  JoinCondition.new(@on, @op, @to)
end

#eq(expression, arel_table: nil) ⇒ Object

Raises:



118
119
120
121
122
# File 'lib/params_ready/query/join_clause.rb', line 118

def eq(expression, arel_table: nil)
  raise ParamsReadyError, "Operator already set" unless @op.nil?
  @op = :eq
  @to = Helpers::ArelBuilder::Attribute.instance(expression, arel_table: arel_table)
end