Class: Pivotable::Expression::Generic

Inherits:
Abstract
  • Object
show all
Defined in:
lib/pivotable/expression/generic.rb

Instance Attribute Summary

Attributes inherited from Abstract

#model, #name, #via

Instance Method Summary collapse

Methods inherited from Abstract

#initialize

Constructor Details

This class inherits a constructor from Pivotable::Expression::Abstract

Instance Method Details

#to_groupObject



13
14
15
# File 'lib/pivotable/expression/generic.rb', line 13

def to_group
  via.clone
end

#to_selectObject



3
4
5
6
7
8
9
10
11
# File 'lib/pivotable/expression/generic.rb', line 3

def to_select
  case via
  when String
    "#{via} AS #{name}"
  else
    sql = Arel::Visitors.visitor_for(model.arel_table.engine).accept via
    "#{sql} AS #{name}"
  end
end