Class: Debugbar::CacheBuffer
- Inherits:
-
Object
- Object
- Debugbar::CacheBuffer
- Defined in:
- lib/debugbar/buffers/cache_buffer.rb
Instance Method Summary collapse
- #clear! ⇒ Object
- #each(&block) ⇒ Object
- #push(request) ⇒ Object
- #remove(ids) ⇒ Object
- #to_h ⇒ Object
Instance Method Details
#clear! ⇒ Object
28 29 30 |
# File 'lib/debugbar/buffers/cache_buffer.rb', line 28 def clear! Rails.cache.delete("debugbar-requests") end |
#each(&block) ⇒ Object
23 24 25 26 |
# File 'lib/debugbar/buffers/cache_buffer.rb', line 23 def each(&block) get_collection.each(&block) end |
#push(request) ⇒ Object
3 4 5 6 7 |
# File 'lib/debugbar/buffers/cache_buffer.rb', line 3 def push(request) collection = get_collection collection[request.id] = request.to_h set_collection(collection) end |
#remove(ids) ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/debugbar/buffers/cache_buffer.rb', line 9 def remove(ids) ids = Array.wrap(ids) collection = get_collection ids.each do |id| collection.delete(id) end set_collection(collection) end |
#to_h ⇒ Object
19 20 21 |
# File 'lib/debugbar/buffers/cache_buffer.rb', line 19 def to_h get_collection.values.map(&:to_h) end |