Class: Debugbar::Request
- Inherits:
-
Object
- Object
- Debugbar::Request
- Defined in:
- lib/debugbar/request.rb
Instance Attribute Summary collapse
-
#cache ⇒ Object
readonly
Returns the value of attribute cache.
-
#headers ⇒ Object
Returns the value of attribute headers.
-
#jobs ⇒ Object
readonly
Returns the value of attribute jobs.
-
#logs ⇒ Object
readonly
Returns the value of attribute logs.
-
#messages ⇒ Object
readonly
Returns the value of attribute messages.
-
#meta ⇒ Object
Returns the value of attribute meta.
-
#models ⇒ Object
readonly
Returns the value of attribute models.
-
#queries ⇒ Object
readonly
Returns the value of attribute queries.
-
#request ⇒ Object
Returns the value of attribute request.
-
#request_id ⇒ Object
(also: #id)
readonly
Returns the value of attribute request_id.
-
#response ⇒ Object
Returns the value of attribute response.
Instance Method Summary collapse
- #add_cache(c) ⇒ Object
- #add_job(job) ⇒ Object
- #add_log(l) ⇒ Object
- #add_msg(msg, extra, source) ⇒ Object
- #add_query(query) ⇒ Object
- #inc_model(name) ⇒ Object
-
#initialize(request_id) ⇒ Request
constructor
A new instance of Request.
- #to_h ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(request_id) ⇒ Request
Returns a new instance of Request.
8 9 10 11 12 13 14 15 16 |
# File 'lib/debugbar/request.rb', line 8 def initialize(request_id) @request_id = request_id @models = {} @queries = [] @jobs = [] @messages = [] @cache = [] @logs = [] end |
Instance Attribute Details
#cache ⇒ Object (readonly)
Returns the value of attribute cache.
3 4 5 |
# File 'lib/debugbar/request.rb', line 3 def cache @cache end |
#headers ⇒ Object
Returns the value of attribute headers.
6 7 8 |
# File 'lib/debugbar/request.rb', line 6 def headers @headers end |
#jobs ⇒ Object (readonly)
Returns the value of attribute jobs.
3 4 5 |
# File 'lib/debugbar/request.rb', line 3 def jobs @jobs end |
#logs ⇒ Object (readonly)
Returns the value of attribute logs.
3 4 5 |
# File 'lib/debugbar/request.rb', line 3 def logs @logs end |
#messages ⇒ Object (readonly)
Returns the value of attribute messages.
3 4 5 |
# File 'lib/debugbar/request.rb', line 3 def @messages end |
#meta ⇒ Object
Returns the value of attribute meta.
3 4 5 |
# File 'lib/debugbar/request.rb', line 3 def @meta end |
#models ⇒ Object (readonly)
Returns the value of attribute models.
3 4 5 |
# File 'lib/debugbar/request.rb', line 3 def models @models end |
#queries ⇒ Object (readonly)
Returns the value of attribute queries.
3 4 5 |
# File 'lib/debugbar/request.rb', line 3 def queries @queries end |
#request ⇒ Object
Returns the value of attribute request.
6 7 8 |
# File 'lib/debugbar/request.rb', line 6 def request @request end |
#request_id ⇒ Object (readonly) Also known as: id
Returns the value of attribute request_id.
3 4 5 |
# File 'lib/debugbar/request.rb', line 3 def request_id @request_id end |
#response ⇒ Object
Returns the value of attribute response.
6 7 8 |
# File 'lib/debugbar/request.rb', line 6 def response @response end |
Instance Method Details
#add_cache(c) ⇒ Object
47 48 49 |
# File 'lib/debugbar/request.rb', line 47 def add_cache(c) @cache << c end |
#add_job(job) ⇒ Object
39 40 41 |
# File 'lib/debugbar/request.rb', line 39 def add_job(job) @jobs << job end |
#add_log(l) ⇒ Object
51 52 53 |
# File 'lib/debugbar/request.rb', line 51 def add_log(l) @logs << l end |
#add_msg(msg, extra, source) ⇒ Object
43 44 45 |
# File 'lib/debugbar/request.rb', line 43 def add_msg(msg, extra, source) @messages << {id: SecureRandom.hex(8), msg: msg, extra: extra, source: source} end |
#add_query(query) ⇒ Object
35 36 37 |
# File 'lib/debugbar/request.rb', line 35 def add_query(query) @queries << query end |
#inc_model(name) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/debugbar/request.rb', line 27 def inc_model(name) if @models[name] @models[name] += 1 else @models[name] = 1 end end |
#to_h ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/debugbar/request.rb', line 55 def to_h { id: request_id, meta: , request: request_hash, response: response_hash, models: models, queries: queries, jobs: jobs, messages: , cache: cache, logs: logs, } end |
#to_json ⇒ Object
70 71 72 |
# File 'lib/debugbar/request.rb', line 70 def to_json JSON.pretty_generate(to_h) end |