Class: ParamsReady::Query::JoinStatement::Builder
- Inherits:
-
Object
- Object
- ParamsReady::Query::JoinStatement::Builder
- Defined in:
- lib/params_ready/query/join_clause.rb
Instance Method Summary collapse
- #build ⇒ Object
-
#initialize(on: nil, eq: nil, &block) ⇒ Builder
constructor
A new instance of Builder.
- #on(expression, arel_table: nil) ⇒ Object
Constructor Details
#initialize(on: nil, eq: nil, &block) ⇒ Builder
Returns a new instance of Builder.
70 71 72 73 74 75 76 77 78 79 |
# File 'lib/params_ready/query/join_clause.rb', line 70 def initialize(on: nil, eq: nil, &block) @condition_builders = [] if on.nil? raise ParamsReadyError, 'Parameter :eq unexpected' unless eq.nil? else condition = on(on) condition.eq(eq) unless eq.nil? end @block = block end |
Instance Method Details
#build ⇒ Object
87 88 89 90 |
# File 'lib/params_ready/query/join_clause.rb', line 87 def build instance_eval(&@block) unless @block.nil? JoinStatement.new(@condition_builders.map(&:build)) end |
#on(expression, arel_table: nil) ⇒ Object
81 82 83 84 85 |
# File 'lib/params_ready/query/join_clause.rb', line 81 def on(expression, arel_table: nil) condition = JoinCondition::Builder.new(expression, arel_table: arel_table) @condition_builders << condition condition end |