Class: Debugbar::MemoryBuffer

Inherits:
Object
  • Object
show all
Defined in:
lib/debugbar/buffers/memory_buffer.rb

Instance Method Summary collapse

Constructor Details

#initializeMemoryBuffer

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_hObject



18
19
20
# File 'lib/debugbar/buffers/memory_buffer.rb', line 18

def to_h
  @collection.values.map(&:to_h)
end