Module: Mobility::Arel::MobilityExpressions

Includes:
Arel::Expressions
Included in:
Attribute
Defined in:
lib/mobility/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.


19
20
21
22
23
# File 'lib/mobility/arel.rb', line 19

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