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

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/dbee/providers/active_record_provider/expression_builder.rb,
lib/dbee/providers/active_record_provider/expression_builder/order_maker.rb,
lib/dbee/providers/active_record_provider/expression_builder/where_maker.rb,
lib/dbee/providers/active_record_provider/expression_builder/select_maker.rb,
lib/dbee/providers/active_record_provider/expression_builder/constraint_maker.rb

Overview

This class can generate an Arel expression tree.

Defined Under Namespace

Classes: ConstraintMaker, MissingConstraintError, OrderMaker, SelectMaker, WhereMaker

Instance Method Summary collapse

Constructor Details

#initialize(model, table_alias_maker, column_alias_maker) ⇒ ExpressionBuilder

Returns a new instance of ExpressionBuilder.



26
27
28
29
30
31
32
# File 'lib/dbee/providers/active_record_provider/expression_builder.rb', line 26

def initialize(model, table_alias_maker, column_alias_maker)
  @model              = model
  @table_alias_maker  = table_alias_maker
  @column_alias_maker = column_alias_maker

  clear
end

Instance Method Details

#add(query) ⇒ Object



42
43
44
45
46
47
48
49
50
# File 'lib/dbee/providers/active_record_provider/expression_builder.rb', line 42

def add(query)
  query.fields.each   { |field| add_field(field) }
  query.sorters.each  { |sorter| add_sorter(sorter) }
  query.filters.each  { |filter| add_filter(filter) }

  add_limit(query.limit)

  self
end

#clearObject



34
35
36
37
38
39
40
# File 'lib/dbee/providers/active_record_provider/expression_builder.rb', line 34

def clear
  @base_table = make_table(model.table, model.name)

  build(base_table)

  add_partitioners(base_table, model.partitioners)
end