Class: Arel::Attribute
- Inherits:
-
Object
- Object
- Arel::Attribute
- Includes:
- Congruence, Expressions, Orderings, Predications, Transformations, Types
- Defined in:
- lib/arel/engines/sql/primitives.rb,
lib/arel/engines/memory/primitives.rb,
lib/arel/algebra/attributes/attribute.rb
Direct Known Subclasses
Arel::Attributes::Boolean, Arel::Attributes::Decimal, Arel::Attributes::Float, Arel::Attributes::Integer, Arel::Attributes::String, Arel::Attributes::Time, Expression
Defined Under Namespace
Modules: Congruence, Expressions, Orderings, Predications, Transformations, Types
Instance Method Summary collapse
- #aggregation? ⇒ Boolean
- #column ⇒ Object
- #eval(row) ⇒ Object
- #format(object) ⇒ Object
-
#initialize(relation, name, options = {}) ⇒ Attribute
constructor
A new instance of Attribute.
- #inspect ⇒ Object
- #named?(hypothetical_name) ⇒ Boolean
- #to_sql(formatter = Sql::WhereCondition.new(relation)) ⇒ Object
Methods included from Types
#type_cast, #type_cast_to_numeric, #typecast_error
Methods included from Orderings
Methods included from Expressions
#average, #count, #maximum, #minimum, #sum
Methods included from 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 Congruence
#/, #descends_from?, #find_correlate_in, #history, #join?, #original_attribute, #original_relation, #root
Methods included from Transformations
#as, #bind, #hash, included, #to_attribute
Constructor Details
#initialize(relation, name, options = {}) ⇒ Attribute
Returns a new instance of Attribute.
10 11 12 |
# File 'lib/arel/algebra/attributes/attribute.rb', line 10 def initialize(relation, name, = {}) @relation, @name, @alias, @ancestor = relation, name, [:alias], [:ancestor] end |
Instance Method Details
#aggregation? ⇒ Boolean
18 19 20 |
# File 'lib/arel/algebra/attributes/attribute.rb', line 18 def aggregation? false end |
#column ⇒ Object
15 16 17 |
# File 'lib/arel/engines/sql/primitives.rb', line 15 def column original_relation.column_for(self) end |
#eval(row) ⇒ Object
3 4 5 |
# File 'lib/arel/engines/memory/primitives.rb', line 3 def eval(row) row[self] end |
#format(object) ⇒ Object
19 20 21 |
# File 'lib/arel/engines/sql/primitives.rb', line 19 def format(object) object.to_sql(Sql::Attribute.new(self)) end |
#inspect ⇒ Object
22 23 24 |
# File 'lib/arel/algebra/attributes/attribute.rb', line 22 def inspect "<Attribute #{name}>" end |
#named?(hypothetical_name) ⇒ Boolean
14 15 16 |
# File 'lib/arel/algebra/attributes/attribute.rb', line 14 def named?(hypothetical_name) (@alias || name).to_s == hypothetical_name.to_s end |
#to_sql(formatter = Sql::WhereCondition.new(relation)) ⇒ Object
23 24 25 |
# File 'lib/arel/engines/sql/primitives.rb', line 23 def to_sql(formatter = Sql::WhereCondition.new(relation)) formatter.attribute self end |