Class: OpenapiContracts::Coverage::Store

Inherits:
Object
  • Object
show all
Defined in:
lib/openapi_contracts/coverage/store.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeStore

Returns a new instance of Store.



5
6
7
# File 'lib/openapi_contracts/coverage/store.rb', line 5

def initialize
  @data = {}
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



3
4
5
# File 'lib/openapi_contracts/coverage/store.rb', line 3

def data
  @data
end

Instance Method Details

#clear!Object



9
10
11
# File 'lib/openapi_contracts/coverage/store.rb', line 9

def clear!
  @data = {}
end

#increment!(path, method, status, media_type) ⇒ Object



13
14
15
16
17
# File 'lib/openapi_contracts/coverage/store.rb', line 13

def increment!(path, method, status, media_type)
  keys = [path, method, status]
  val = @data.dig(*keys) || Hash.new(0).tap { |h| OpenapiContracts.hash_bury!(@data, keys, h) }
  val[media_type] += 1
end