Class: Squeel::Visitors::SymbolVisitor
- Inherits:
-
Base
- Object
- Base
- Squeel::Visitors::SymbolVisitor
show all
- Defined in:
- lib/squeel/visitors/symbol_visitor.rb
Constant Summary
Constants inherited
from Base
Base::DISPATCH
Instance Attribute Summary
Attributes inherited from Base
#context
Instance Method Summary
collapse
Methods inherited from Base
#can_accept?, can_accept?, #quote, #quoted?, #visit
Constructor Details
Returns a new instance of SymbolVisitor.
7
8
|
# File 'lib/squeel/visitors/symbol_visitor.rb', line 7
def initialize
end
|
Instance Method Details
#accept(object, parent = nil) ⇒ Object
10
11
12
|
# File 'lib/squeel/visitors/symbol_visitor.rb', line 10
def accept(object, parent = nil)
visit(object, parent)
end
|
#visit_Array(o, parent) ⇒ Object
16
17
18
|
# File 'lib/squeel/visitors/symbol_visitor.rb', line 16
def visit_Array(o, parent)
o.map {|e| accept(e, parent)}.flatten
end
|
#visit_Hash(o, parent) ⇒ Object
20
21
22
23
24
25
26
|
# File 'lib/squeel/visitors/symbol_visitor.rb', line 20
def visit_Hash(o, parent)
{}.tap do |hash|
o.each do |key, value|
hash[accept(key, parent)] = accept(value, parent)
end
end
end
|
#visit_Squeel_Nodes_Join(o, parent) ⇒ Object
42
43
44
|
# File 'lib/squeel/visitors/symbol_visitor.rb', line 42
def visit_Squeel_Nodes_Join(o, parent)
o._name
end
|
#visit_Squeel_Nodes_KeyPath(o, parent) ⇒ Object
36
37
38
39
40
|
# File 'lib/squeel/visitors/symbol_visitor.rb', line 36
def visit_Squeel_Nodes_KeyPath(o, parent)
o.path_with_endpoint.reverse.map(&:to_sym).inject do |hash, key|
{key => hash}
end
end
|
#visit_Squeel_Nodes_Stub(o, parent) ⇒ Object
32
33
34
|
# File 'lib/squeel/visitors/symbol_visitor.rb', line 32
def visit_Squeel_Nodes_Stub(o, parent)
o.symbol
end
|
#visit_Symbol(o, parent) ⇒ Object
28
29
30
|
# File 'lib/squeel/visitors/symbol_visitor.rb', line 28
def visit_Symbol(o, parent)
o
end
|