Class: Arel::Table
Class Attribute Summary collapse
Instance Attribute Summary collapse
Instance Method Summary
collapse
#as
#coalesce, #create_and, #create_false, #create_join, #create_on, #create_string_join, #create_table_alias, #create_true, #grouping, #lower
Methods included from Crud
#compile_delete, #compile_insert, #compile_update, #create_insert
Constructor Details
#initialize(name, as: nil, klass: nil, type_caster: klass&.type_caster) ⇒ Table
Returns a new instance of Table.
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/arel/table.rb', line 17
def initialize(name, as: nil, klass: nil, type_caster: klass&.type_caster)
@name = name.to_s
@klass = klass
@type_caster = type_caster
if as.to_s == @name
as = nil
end
@table_alias = as
end
|
Class Attribute Details
.engine ⇒ Object
Returns the value of attribute engine.
10
11
12
|
# File 'lib/arel/table.rb', line 10
def engine
@engine
end
|
Instance Attribute Details
#name ⇒ Object
Also known as:
table_name
Returns the value of attribute name.
12
13
14
|
# File 'lib/arel/table.rb', line 12
def name
@name
end
|
#table_alias ⇒ Object
Returns the value of attribute table_alias.
12
13
14
|
# File 'lib/arel/table.rb', line 12
def table_alias
@table_alias
end
|
Instance Method Details
#[](name, table = self) ⇒ Object
83
84
85
86
87
|
# File 'lib/arel/table.rb', line 83
def [](name, table = self)
name = name.to_s if name.is_a?(Symbol)
name = @klass.attribute_aliases[name] || name if @klass
Attribute.new(table, name)
end
|
#able_to_type_cast? ⇒ Boolean
111
112
113
|
# File 'lib/arel/table.rb', line 111
def able_to_type_cast?
!type_caster.nil?
end
|
#alias(name = "#{self.name}_2") ⇒ Object
31
32
33
|
# File 'lib/arel/table.rb', line 31
def alias(name = "#{self.name}_2")
Nodes::TableAlias.new(self, name)
end
|
#eql?(other) ⇒ Boolean
Also known as:
==
96
97
98
99
100
|
# File 'lib/arel/table.rb', line 96
def eql?(other)
self.class == other.class &&
self.name == other.name &&
self.table_alias == other.table_alias
end
|
#from ⇒ Object
35
36
37
|
# File 'lib/arel/table.rb', line 35
def from
SelectManager.new(self)
end
|
#group(*columns) ⇒ Object
55
56
57
|
# File 'lib/arel/table.rb', line 55
def group(*columns)
from.group(*columns)
end
|
#hash ⇒ Object
89
90
91
92
93
94
|
# File 'lib/arel/table.rb', line 89
def hash
@name.hash
end
|
#having(expr) ⇒ Object
79
80
81
|
# File 'lib/arel/table.rb', line 79
def having(expr)
from.having expr
end
|
#join(relation, klass = Nodes::InnerJoin) ⇒ Object
#order(*expr) ⇒ Object
59
60
61
|
# File 'lib/arel/table.rb', line 59
def order(*expr)
from.order(*expr)
end
|
#outer_join(relation) ⇒ Object
51
52
53
|
# File 'lib/arel/table.rb', line 51
def outer_join(relation)
join(relation, Nodes::OuterJoin)
end
|
#project(*things) ⇒ Object
67
68
69
|
# File 'lib/arel/table.rb', line 67
def project(*things)
from.project(*things)
end
|
#skip(amount) ⇒ Object
75
76
77
|
# File 'lib/arel/table.rb', line 75
def skip(amount)
from.skip amount
end
|
#take(amount) ⇒ Object
71
72
73
|
# File 'lib/arel/table.rb', line 71
def take(amount)
from.take amount
end
|
#type_cast_for_database(attr_name, value) ⇒ Object
103
104
105
|
# File 'lib/arel/table.rb', line 103
def type_cast_for_database(attr_name, value)
type_caster.type_cast_for_database(attr_name, value)
end
|
#type_for_attribute(name) ⇒ Object
107
108
109
|
# File 'lib/arel/table.rb', line 107
def type_for_attribute(name)
type_caster.type_for_attribute(name)
end
|
#where(condition) ⇒ Object
63
64
65
|
# File 'lib/arel/table.rb', line 63
def where(condition)
from.where condition
end
|