Class: Dbee::Providers::ActiveRecordProvider::Makers::Select

Inherits:
Object
  • Object
show all
Defined in:
lib/dbee/providers/active_record_provider/makers/select.rb

Overview

Derives Arel#project predicates.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(alias_maker) ⇒ Select

Returns a new instance of Select.



18
19
20
21
22
# File 'lib/dbee/providers/active_record_provider/makers/select.rb', line 18

def initialize(alias_maker)
  @alias_maker = alias_maker

  freeze
end

Instance Attribute Details

#alias_makerObject (readonly)

Returns the value of attribute alias_maker.



16
17
18
# File 'lib/dbee/providers/active_record_provider/makers/select.rb', line 16

def alias_maker
  @alias_maker
end

Instance Method Details

#make(field, arel_key_nodes_to_filters, arel_value_node) ⇒ Object



28
29
30
31
32
33
34
# File 'lib/dbee/providers/active_record_provider/makers/select.rb', line 28

def make(field, arel_key_nodes_to_filters, arel_value_node)
  column_alias = quote(alias_maker.make(field.display))
  predicate    = expression(field, arel_key_nodes_to_filters, arel_value_node)
  predicate    = aggregate(field, predicate)

  predicate.as(column_alias)
end

#star(arel_table) ⇒ Object



24
25
26
# File 'lib/dbee/providers/active_record_provider/makers/select.rb', line 24

def star(arel_table)
  arel_table[Arel.star]
end