Class: Arel::Expression

Inherits:
Attribute show all
Includes:
Transformations
Defined in:
lib/arel/algebra/expression.rb,
lib/arel/engines/sql/primitives.rb

Direct Known Subclasses

Average, Count, Distinct, Maximum, Minimum, Sum

Defined Under Namespace

Modules: Transformations

Instance Method Summary collapse

Methods included from Transformations

#as, #bind, #to_attribute

Methods inherited from Attribute

#column, #eval, #format, #named?

Methods included from Attribute::Types

#type_cast, #type_cast_to_numeric, #typecast_error

Methods included from Attribute::Orderings

#asc, #desc

Methods included from Attribute::Expressions

#average, #count, #maximum, #minimum, #sum

Methods included from Attribute::Predications

#eq, #eq_all, #eq_any, #gt, #gt_all, #gt_any, #gteq, #gteq_all, #gteq_any, #in, #in_all, #in_any, #lt, #lt_all, #lt_any, #lteq, #lteq_all, #lteq_any, #matches, #matches_all, #matches_any, #not_eq, #not_eq_all, #not_eq_any, #not_in, #not_in_all, #not_in_any, #not_matches, #not_matches_all, #not_matches_any

Methods included from Attribute::Congruence

#/, #descends_from?, #find_correlate_in, #history, #join?, #original_attribute, #original_relation, #root

Methods included from Attribute::Transformations

#as, #bind, #hash, included, #to_attribute

Constructor Details

#initialize(attribute, aliaz = nil, ancestor = nil) ⇒ Expression

Returns a new instance of Expression.



8
9
10
# File 'lib/arel/algebra/expression.rb', line 8

def initialize(attribute, aliaz = nil, ancestor = nil)
  @attribute, @alias, @ancestor = attribute, aliaz, ancestor
end

Instance Method Details

#aggregation?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/arel/algebra/expression.rb', line 12

def aggregation?
  true
end

#inspectObject



16
17
18
# File 'lib/arel/algebra/expression.rb', line 16

def inspect
  "<#{self.class.name} #{attribute.inspect}>"
end

#to_sql(formatter = Sql::SelectClause.new(relation)) ⇒ Object



69
70
71
# File 'lib/arel/engines/sql/primitives.rb', line 69

def to_sql(formatter = Sql::SelectClause.new(relation))
  formatter.expression self
end