Module: Mobility::Plugins::Arel::MobilityExpressions

Includes:
Arel::Expressions
Included in:
Attribute
Defined in:
lib/mobility/plugins/arel.rb

Defined Under Namespace

Modules: Countable

Instance Method Summary collapse

Instance Method Details

#asObject

Note:

This is necessary in order to ensure that when a translated attribute is selected with an alias using AS, the resulting expression can still be counted without blowing up.

Extending ::Arel::Expressions is necessary to convince ActiveRecord that this node should not be stringified, which otherwise would result in garbage SQL.



26
27
28
29
30
# File 'lib/mobility/plugins/arel.rb', line 26

def as(*)
  super
    .extend(::Arel::Expressions)
    .extend(Countable)
end