Class: Dbee::Providers::ActiveRecordProvider::Makers::Constraint

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/dbee/providers/active_record_provider/makers/constraint.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



18
19
20
21
22
23
24
25
26
# File 'lib/dbee/providers/active_record_provider/makers/constraint.rb', line 18

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