Class: Queris::Query::Trace
- Inherits:
-
Object
- Object
- Queris::Query::Trace
show all
- Defined in:
- lib/queris/query/trace.rb
Defined Under Namespace
Classes: TraceBase, TraceMessage, TraceOp
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(query, opt = {}) ⇒ Trace
Returns a new instance of Trace.
74
75
76
77
78
79
|
# File 'lib/queris/query/trace.rb', line 74
def initialize(query, opt={})
@query=query
@buffer = []
@indentation = 0
@options= Hash === opt ? opt : {}
end
|
Instance Attribute Details
#buffer ⇒ Object
Returns the value of attribute buffer.
73
74
75
|
# File 'lib/queris/query/trace.rb', line 73
def buffer
@buffer
end
|
Instance Method Details
#indent(n = 1) ⇒ Object
88
89
90
91
92
|
# File 'lib/queris/query/trace.rb', line 88
def indent(n=1)
@indentation += n
@buffer.each { |line| line.indent n }
self
end
|
#message(text) ⇒ Object
99
100
101
102
103
104
|
# File 'lib/queris/query/trace.rb', line 99
def message(text)
t = TraceMessage.new(text)
t.set_options @options
buffer << t
self
end
|
#op(*arg) ⇒ Object
93
94
95
96
97
98
|
# File 'lib/queris/query/trace.rb', line 93
def op(*arg)
t = TraceOp.new(@query.redis, *arg)
t.set_options @options
buffer << t
self
end
|
#to_s ⇒ Object
80
81
82
83
84
85
86
87
|
# File 'lib/queris/query/trace.rb', line 80
def to_s
out=[]
buffer.each do |line|
out << line.to_s
out << line.subquery.trace(@indentation + 1) if line.respond_to?(:subquery) && line.subquery
end
out.join "\r\n"
end
|