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 is our shim to get our functionality into rails
Instance Attribute Summary collapse
-
#klass ⇒ Object
Returns the value of attribute klass.
Instance Method Summary collapse
-
#[](name, table = self) ⇒ Object
overrides Arel::Table#[] adds aliases and virtual attribute arel (aka sql).
Instance Attribute Details
#klass ⇒ Object
Returns the value of attribute klass.
41 42 43 |
# File 'lib/active_record/virtual_attributes/virtual_arel.rb', line 41 def klass @klass end |
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
53 54 55 56 57 58 59 60 61 62 |
# File 'lib/active_record/virtual_attributes/virtual_arel.rb', line 53 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 |