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


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

def to_group
  via.clone
end

#to_selectObject


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

def to_select
  case via
  when String
    "#{via} AS #{name}"
  else
    via.as(name).to_sql.tap do |s|
      s.sub!(/AS .+$/, "AS #{name}") if Arel::VERSION < "2.1.0"
    end
  end
end