class TShield::Counter

Increment counter for sessions requests

Public Class Methods

new() click to toggle source
# File lib/tshield/counter.rb, line 6
def initialize
  @requests = {}
end

Public Instance Methods

add(callid, method) click to toggle source
# File lib/tshield/counter.rb, line 10
def add(callid, method)
  requests_to_callid = @requests.fetch(callid, {})
  requests_to_method = requests_to_callid.fetch(method, 0)

  requests_to_callid[method] = requests_to_method + 1
  @requests[callid] = requests_to_callid
end
current(callid, method) click to toggle source
# File lib/tshield/counter.rb, line 18
def current(callid, method)
  @requests.fetch(callid, {}).fetch(method, 0)
end
to_json(options = {}) click to toggle source
# File lib/tshield/counter.rb, line 22
def to_json(options = {})
  @requests.to_json(options)
end