class Arel::Table
Attributes
engine[RW]
name[RW]
table_alias[RW]
table_name[RW]
type_caster[R]
Public Class Methods
new(name, as: nil, type_caster: nil)
click to toggle source
# File lib/arel/table.rb, line 14 def initialize(name, as: nil, type_caster: nil) @name = name.to_s @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
Public Instance Methods
[](name)
click to toggle source
# File lib/arel/table.rb, line 79 def [] name ::Arel::Attribute.new self, name end
able_to_type_cast?()
click to toggle source
# File lib/arel/table.rb, line 101 def able_to_type_cast? !type_caster.nil? end
alias(name = "
click to toggle source
# File lib/arel/table.rb, line 27 def alias name = "#{self.name}_2" Nodes::TableAlias.new(self, name) end
eql?(other)
click to toggle source
# File lib/arel/table.rb, line 90 def eql? other self.class == other.class && self.name == other.name && self.table_alias == other.table_alias end
Also aliased as: ==
from()
click to toggle source
# File lib/arel/table.rb, line 31 def from SelectManager.new(self) end
group(*columns)
click to toggle source
# File lib/arel/table.rb, line 51 def group *columns from.group(*columns) end
hash()
click to toggle source
# File lib/arel/table.rb, line 83 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)
click to toggle source
# File lib/arel/table.rb, line 75 def having expr from.having expr end
join(relation, klass = Nodes::InnerJoin)
click to toggle source
# File lib/arel/table.rb, line 35 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)
click to toggle source
# File lib/arel/table.rb, line 55 def order *expr from.order(*expr) end
outer_join(relation)
click to toggle source
# File lib/arel/table.rb, line 47 def outer_join relation join(relation, Nodes::OuterJoin) end
project(*things)
click to toggle source
# File lib/arel/table.rb, line 63 def project *things from.project(*things) end
skip(amount)
click to toggle source
# File lib/arel/table.rb, line 71 def skip amount from.skip amount end
take(amount)
click to toggle source
# File lib/arel/table.rb, line 67 def take amount from.take amount end
type_cast_for_database(attribute_name, value)
click to toggle source
# File lib/arel/table.rb, line 97 def type_cast_for_database(attribute_name, value) type_caster.type_cast_for_database(attribute_name, value) end
where(condition)
click to toggle source
# File lib/arel/table.rb, line 59 def where condition from.where condition end