Class: Apiwork::ErrorCode::Registry

Inherits:
Registry
  • Object
show all
Defined in:
lib/apiwork/error_code/registry.rb

Class Method Summary collapse

Methods inherited from Registry

clear!, delete, exists?, find, find!, keys, store, values

Class Method Details

.register(key, attach_path: false, status:) ⇒ Object

Raises:

  • (ArgumentError)


7
8
9
10
11
12
13
14
# File 'lib/apiwork/error_code/registry.rb', line 7

def register(key, attach_path: false, status:)
  key = normalize_key(key)
  status = Integer(status)

  raise ArgumentError, "Status must be 400-599, got #{status}" unless (400..599).cover?(status)

  store[key] = Definition.new(attach_path:, key:, status:)
end