Class: Arel::Expression
- Defined in:
- lib/arel/algebra/expression.rb
Constant Summary
Constants inherited from Attribute
Attribute::PREDICATES, Attribute::Predications
Instance Attribute Summary collapse
-
#attribute ⇒ Object
readonly
Returns the value of attribute attribute.
Attributes inherited from Attribute
#alias, #ancestor, #hash, #history, #relation
Instance Method Summary collapse
- #aggregation? ⇒ Boolean
- #as(aliaz) ⇒ Object
- #bind(new_relation) ⇒ Object
-
#initialize(attribute, aliaz = nil, ancestor = nil) ⇒ Expression
constructor
A new instance of Expression.
- #to_attribute(relation) ⇒ Object
- #to_sql(formatter = Sql::SelectClause.new(relation)) ⇒ Object
Methods inherited from Attribute
#/, #==, #christener, #column, #descends_from?, #engine, #eq, #eq_all, #eq_any, #eval, #find_correlate_in, #format, #gt, #gt_all, #gt_any, #gteq, #gteq_all, #gteq_any, #in, #in_all, #in_any, #join?, #lt, #lt_all, #lt_any, #lteq, #lteq_all, #lteq_any, #matches, #matches_all, #matches_any, #named?, #not_eq, #not_eq_all, #not_eq_any, #not_in, #not_in_all, #not_in_any, #not_matches, #not_matches_all, #not_matches_any, #original_attribute, #original_relation, #root
Methods included from Attribute::Types
#type_cast, #type_cast_to_numeric, #typecast_error
Methods included from Attribute::Orderings
Methods included from Attribute::Expressions
#average, #count, #maximum, #minimum, #sum
Constructor Details
#initialize(attribute, aliaz = nil, ancestor = nil) ⇒ Expression
Returns a new instance of Expression.
6 7 8 9 |
# File 'lib/arel/algebra/expression.rb', line 6 def initialize(attribute, aliaz = nil, ancestor = nil) super(attribute.relation, aliaz, :alias => aliaz, :ancestor => ancestor) @attribute = attribute end |
Instance Attribute Details
#attribute ⇒ Object (readonly)
Returns the value of attribute attribute.
3 4 5 |
# File 'lib/arel/algebra/expression.rb', line 3 def attribute @attribute end |
Instance Method Details
#aggregation? ⇒ Boolean
11 12 13 |
# File 'lib/arel/algebra/expression.rb', line 11 def aggregation? true end |
#as(aliaz) ⇒ Object
19 20 21 |
# File 'lib/arel/algebra/expression.rb', line 19 def as(aliaz) self.class.new(attribute, aliaz, self) end |
#bind(new_relation) ⇒ Object
23 24 25 |
# File 'lib/arel/algebra/expression.rb', line 23 def bind(new_relation) new_relation == relation ? self : self.class.new(attribute.bind(new_relation), @alias, self) end |
#to_attribute(relation) ⇒ Object
27 28 29 |
# File 'lib/arel/algebra/expression.rb', line 27 def to_attribute(relation) Attribute.new(relation, @alias, :ancestor => self) end |
#to_sql(formatter = Sql::SelectClause.new(relation)) ⇒ Object
15 16 17 |
# File 'lib/arel/algebra/expression.rb', line 15 def to_sql(formatter = Sql::SelectClause.new(relation)) formatter.expression self end |