Class: Debugbar::MemoryBuffer
- Inherits:
-
Object
- Object
- Debugbar::MemoryBuffer
- Defined in:
- lib/debugbar/buffers/memory_buffer.rb
Instance Method Summary collapse
- #clear! ⇒ Object
- #each(&block) ⇒ Object
-
#initialize ⇒ MemoryBuffer
constructor
A new instance of MemoryBuffer.
- #push(request) ⇒ Object
- #remove(ids) ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize ⇒ MemoryBuffer
Returns a new instance of MemoryBuffer.
3 4 5 |
# File 'lib/debugbar/buffers/memory_buffer.rb', line 3 def initialize @collection = {} end |
Instance Method Details
#clear! ⇒ Object
26 27 28 |
# File 'lib/debugbar/buffers/memory_buffer.rb', line 26 def clear! @collection = {} end |
#each(&block) ⇒ Object
22 23 24 |
# File 'lib/debugbar/buffers/memory_buffer.rb', line 22 def each(&block) @collection.each(&block) end |
#push(request) ⇒ Object
7 8 9 |
# File 'lib/debugbar/buffers/memory_buffer.rb', line 7 def push(request) @collection[request.id] = request end |
#remove(ids) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/debugbar/buffers/memory_buffer.rb', line 11 def remove(ids) ids = Array.wrap(ids) ids.each do |id| @collection.delete(id) end end |
#to_h ⇒ Object
18 19 20 |
# File 'lib/debugbar/buffers/memory_buffer.rb', line 18 def to_h @collection.values.map(&:to_h) end |