Module: Rack::Insight::Database::RequestDataClient
- Included in:
- Panel, SpeedTracer::TraceApp
- Defined in:
- lib/rack/insight/database.rb
Overview
Classes including this module must define the following structure:
class FooBar
include Rack::Insight::Database
class << self
attr_accessor :has_table
end
# Setting as below is only required when not using a table (Why are you including this module then?)
# self.has_table = false
end
TODO: Move the has_table definition into this module’s included hook.
Instance Method Summary collapse
- #count(request_id) ⇒ Object
- #key_sql_template(sql) ⇒ Object
- #retrieve(request_id) ⇒ Object
- #store(env, *keys_and_value) ⇒ Object
- #table_length ⇒ Object
- #table_setup(name, *keys) ⇒ Object
Instance Method Details
#count(request_id) ⇒ Object
59 60 61 |
# File 'lib/rack/insight/database.rb', line 59 def count(request_id) self.class.table.count_for_request(request_id) end |
#key_sql_template(sql) ⇒ Object
26 27 28 |
# File 'lib/rack/insight/database.rb', line 26 def key_sql_template(sql) self.class.key_sql_template = sql end |
#retrieve(request_id) ⇒ Object
55 56 57 |
# File 'lib/rack/insight/database.rb', line 55 def retrieve(request_id) self.class.table.for_request(request_id) end |
#store(env, *keys_and_value) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/rack/insight/database.rb', line 39 def store(env, *keys_and_value) return if env.nil? request_id = env["rack-insight.request-id"] return if request_id.nil? value = keys_and_value[-1] keys = keys_and_value[0...-1] #puts "value: #{value}" #puts "keys: #{keys}" #puts "table: #{self.class.table.inspect}" #puts "@key_sql_template: #{self.class.key_sql_template}" #puts "class: #{self.class.inspect}" self.class.table.store(request_id, value, self.class.key_sql_template % keys) end |
#table_length ⇒ Object
63 64 65 |
# File 'lib/rack/insight/database.rb', line 63 def table_length self.class.table.length end |