Module: Webmachine::Trace
- Defined in:
- lib/webmachine/trace.rb,
lib/webmachine/trace/fsm.rb,
lib/webmachine/trace/resource_proxy.rb,
lib/webmachine/trace/trace_resource.rb,
lib/webmachine/trace/pstore_trace_store.rb
Overview
Contains means to enable the Webmachine visual debugger.
Defined Under Namespace
Modules: FSM Classes: PStoreTraceStore, ResourceProxy, TraceResource
Constant Summary collapse
- TRACE_STORES =
Classes that implement storage for visual debugger traces.
{ :memory => Hash, :pstore => PStoreTraceStore }
Class Method Summary collapse
-
.fetch(key) ⇒ Array
private
Fetches a given trace from the trace store.
-
.record(key, trace) ⇒ Object
private
Records a trace from a processed request.
-
.trace?(resource) ⇒ true, false
Determines whether this resource instance should be traced.
- .trace_store ⇒ Object
-
.trace_store=(*args) ⇒ Object
Sets the trace storage method.
-
.traces ⇒ Array<String>
private
Retrieves keys of traces that have been recorded.
Class Method Details
.fetch(key) ⇒ Array
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Fetches a given trace from the trace store. This is used to send specific trace information to the visual debugger.
50 51 52 |
# File 'lib/webmachine/trace.rb', line 50 def fetch(key) trace_store.fetch(key) end |
.record(key, trace) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Records a trace from a processed request. This is automatically called by ResourceProxy when finishing the request.
33 34 35 |
# File 'lib/webmachine/trace.rb', line 33 def record(key, trace) trace_store[key] = trace end |
.trace?(resource) ⇒ true, false
Determines whether this resource instance should be traced.
19 20 21 22 23 24 |
# File 'lib/webmachine/trace.rb', line 19 def trace?(resource) # For now this defers to the resource to enable tracing in the # initialize method. At a later time, we can add tracing at the # Application level, perhaps. resource.trace? end |
.trace_store ⇒ Object
65 66 67 68 69 70 71 |
# File 'lib/webmachine/trace.rb', line 65 def trace_store @trace_store ||= begin opts = Array(@trace_store_opts).dup type = opts.shift TRACE_STORES[type].new(*opts) end end |
.trace_store=(*args) ⇒ Object
Sets the trace storage method. The first parameter should be a Symbol, followed by any additional options for the store. Defaults to :memory, which is an in-memory Hash.
59 60 61 62 |
# File 'lib/webmachine/trace.rb', line 59 def trace_store=(*args) @trace_store = nil @trace_store_opts = args end |
.traces ⇒ Array<String>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Retrieves keys of traces that have been recorded. This is used to present a list of available traces in the visual debugger.
41 42 43 |
# File 'lib/webmachine/trace.rb', line 41 def traces trace_store.keys end |