Class: ActiveRecord::VirtualAttributes::VirtualArel::ArelTableProxy
- Inherits:
-
Arel::Table
- Object
- Arel::Table
- ActiveRecord::VirtualAttributes::VirtualArel::ArelTableProxy
- Defined in:
- lib/active_record/virtual_attributes/virtual_arel.rb
Overview
This arel table proxy. This allows WHERE clauses to use virtual attributes
Instance Method Summary collapse
-
#[](name, table = self) ⇒ Object
overrides Arel::Table#[] adds aliases and virtual attribute arel (aka sql).
Instance Method Details
#[](name, table = self) ⇒ Object
overrides Arel::Table#[] adds aliases and virtual attribute arel (aka sql)
for regular database columns:
returns an Arel::Attribute (just like Arel::Table#[])
for virtual attributes:
returns the arel for the value
for non sql friendly virtual attributes:
returns nil
56 57 58 59 60 61 62 63 64 65 |
# File 'lib/active_record/virtual_attributes/virtual_arel.rb', line 56 def [](name, table = self) if (col_alias = @klass.attribute_alias(name)) name = col_alias end if @klass.virtual_attribute?(name) @klass.arel_for_virtual_attribute(name, table) else super end end |