Class: Arel::Table
Do not use. This class is for internal use only.
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Instance Chain:
self,
AliasPredication ,
FactoryMethods
|
|
Inherits: | Object |
Defined in: | activerecord/lib/arel/table.rb |
Class Attribute Summary
- .engine rw
Class Method Summary
Instance Attribute Summary
- #able_to_type_cast? ⇒ Boolean readonly
- #name rw
- #table_alias readonly
- #type_caster readonly private
Instance Method Summary
-
#==(other)
Alias for #eql?.
- #[](name, table = self)
- #alias(name = "#{self.name}_2")
- #eql?(other) ⇒ Boolean (also: #==)
- #from
- #group(*columns)
- #hash
- #having(expr)
- #join(relation, klass = Nodes::InnerJoin)
- #order(*expr)
- #outer_join(relation)
- #project(*things)
- #skip(amount)
- #take(amount)
- #type_cast_for_database(attr_name, value)
- #type_for_attribute(name)
- #where(condition)
AliasPredication
- Included
FactoryMethods
- Included
#cast, #coalesce, #create_and, #create_false, #create_join, #create_on, #create_string_join, #create_table_alias, #create_true, #grouping, | |
#lower | Create a LOWER() function. |
Constructor Details
.new(name, as: nil, klass: nil, type_caster: klass&.type_caster) ⇒ Table
# File 'activerecord/lib/arel/table.rb', line 14
def initialize(name, as: nil, klass: nil, type_caster: klass&.type_caster) name = name.name if name.is_a?(Symbol) @name = name @klass = klass @type_caster = type_caster # Sometime AR sends an :as parameter to table, to let the table know # that it is an Alias. We may want to override new, and return a # TableAlias node? if as.to_s == @name as = nil end @table_alias = as end
Class Attribute Details
.engine (rw)
[ GitHub ]# File 'activerecord/lib/arel/table.rb', line 9
class << self; attr_accessor :engine; end
Instance Attribute Details
#able_to_type_cast? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'activerecord/lib/arel/table.rb', line 110
def able_to_type_cast? !type_caster.nil? end
#name (rw)
[ GitHub ]# File 'activerecord/lib/arel/table.rb', line 11
attr_accessor :name
#table_alias (readonly)
[ GitHub ]# File 'activerecord/lib/arel/table.rb', line 12
attr_reader :table_alias
#type_caster (readonly, private)
[ GitHub ]# File 'activerecord/lib/arel/table.rb', line 115
attr_reader :type_caster
Instance Method Details
#==(other)
Alias for #eql?.
# File 'activerecord/lib/arel/table.rb', line 100
alias :== :eql?
#[](name, table = self)
[ GitHub ]#alias(name = "#{self.name}_2")
[ GitHub ]
#eql?(other) ⇒ Boolean
Also known as: #==
# File 'activerecord/lib/arel/table.rb', line 95
def eql?(other) self.class == other.class && self.name == other.name && self.table_alias == other.table_alias end
#from
[ GitHub ]# File 'activerecord/lib/arel/table.rb', line 34
def from SelectManager.new(self) end
#group(*columns)
[ GitHub ]# File 'activerecord/lib/arel/table.rb', line 54
def group(*columns) from.group(*columns) end
#hash
[ GitHub ]# File 'activerecord/lib/arel/table.rb', line 88
def hash # Perf note: aliases and table alias is excluded from the hash # aliases can have a loop back to this table breaking hashes in parent # relations, for the vast majority of cases @name is unique to a query @name.hash end
#having(expr)
[ GitHub ]# File 'activerecord/lib/arel/table.rb', line 78
def having(expr) from.having expr end
#join(relation, klass = Nodes::InnerJoin)
[ GitHub ]# File 'activerecord/lib/arel/table.rb', line 38
def join(relation, klass = Nodes::InnerJoin) return from unless relation case relation when String, Nodes::SqlLiteral raise EmptyJoinError if relation.empty? klass = Nodes::StringJoin end from.join(relation, klass) end
#order(*expr)
[ GitHub ]# File 'activerecord/lib/arel/table.rb', line 58
def order(*expr) from.order(*expr) end
#outer_join(relation)
[ GitHub ]#project(*things)
[ GitHub ]# File 'activerecord/lib/arel/table.rb', line 66
def project(*things) from.project(*things) end
#skip(amount)
[ GitHub ]# File 'activerecord/lib/arel/table.rb', line 74
def skip(amount) from.skip amount end
#take(amount)
[ GitHub ]# File 'activerecord/lib/arel/table.rb', line 70
def take(amount) from.take amount end
#type_cast_for_database(attr_name, value)
[ GitHub ]# File 'activerecord/lib/arel/table.rb', line 102
def type_cast_for_database(attr_name, value) type_caster.type_cast_for_database(attr_name, value) end
#type_for_attribute(name)
[ GitHub ]# File 'activerecord/lib/arel/table.rb', line 106
def type_for_attribute(name) type_caster.type_for_attribute(name) end
#where(condition)
[ GitHub ]# File 'activerecord/lib/arel/table.rb', line 62
def where(condition) from.where condition end