Class: Debugbar::CacheBuffer

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

Instance Method Summary collapse

Instance Method Details

#clear!Object



32
33
34
# File 'lib/debugbar/buffers/cache_buffer.rb', line 32

def clear!
  Rails.cache.delete("debugbar-requests")
end

#each(&block) ⇒ Object



27
28
29
30
# File 'lib/debugbar/buffers/cache_buffer.rb', line 27

def each(&block)
  get_collection.each(&block)

end

#get(id) ⇒ Object



3
4
5
# File 'lib/debugbar/buffers/cache_buffer.rb', line 3

def get(id)
  get_collection[id].to_h
end

#push(request) ⇒ Object



7
8
9
10
11
# File 'lib/debugbar/buffers/cache_buffer.rb', line 7

def push(request)
  collection = get_collection
  collection[request.id] = request.to_h
  set_collection(collection)
end

#remove(ids) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/debugbar/buffers/cache_buffer.rb', line 13

def remove(ids)
  ids = Array.wrap(ids)

  collection = get_collection
  ids.each do |id|
    collection.delete(id)
  end
  set_collection(collection)
end

#to_hObject



23
24
25
# File 'lib/debugbar/buffers/cache_buffer.rb', line 23

def to_h
  get_collection.values.map(&:to_h)
end