Class: Dbee::Providers::ActiveRecordProvider::ExpressionBuilder::ConstraintMaker

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/dbee/providers/active_record_provider/expression_builder/constraint_maker.rb

Overview

Can derive constraints for Arel table JOIN statements.

Constant Summary collapse

CONCAT_METHOD =
lambda do |on, arel_column, value|
  on ? on.and(arel_column.eq(value)) : arel_column.eq(value)
end

Instance Method Summary collapse

Instance Method Details

#make(constraints, table, previous_table) ⇒ Object



48
49
50
51
52
53
54
55
56
# File 'lib/dbee/providers/active_record_provider/expression_builder/constraint_maker.rb', line 48

def make(constraints, table, previous_table)
  constraints.inject(nil) do |memo, constraint|
    method = CONSTRAINT_RESOLVERS[constraint.class]

    raise ArgumentError, "constraint unhandled: #{constraint.class.name}" unless method

    method.call(constraint, memo, table, previous_table)
  end
end