Class: ParamsReady::Query::JoinCondition
- Inherits:
-
Object
- Object
- ParamsReady::Query::JoinCondition
- Defined in:
- lib/params_ready/query/join_clause.rb
Defined Under Namespace
Classes: Builder
Instance Method Summary collapse
-
#initialize(on, op, to) ⇒ JoinCondition
constructor
A new instance of JoinCondition.
- #to_arel(base_table, join_table, context, parameter) ⇒ Object
Constructor Details
#initialize(on, op, to) ⇒ JoinCondition
Returns a new instance of JoinCondition.
129 130 131 132 133 134 |
# File 'lib/params_ready/query/join_clause.rb', line 129 def initialize(on, op, to) @on = on @op = op @to = to freeze end |
Instance Method Details
#to_arel(base_table, join_table, context, parameter) ⇒ Object
136 137 138 139 140 141 142 143 144 145 146 147 |
# File 'lib/params_ready/query/join_clause.rb', line 136 def to_arel(base_table, join_table, context, parameter) if @to.nil? grouping = @on.to_arel(:none, context, parameter) return grouping if grouping.is_a? Arel::Nodes::Node Arel::Nodes::Grouping.new(grouping) else lhs = @on.to_arel(base_table, context, parameter) rhs = @to.to_arel(join_table, context, parameter) lhs.send(@op, rhs) end end |