Module: ErrorResponse
- Defined in:
- lib/error_response.rb,
lib/error_response/helper.rb,
lib/error_response/configuration.rb,
lib/error_response/request_error.rb
Defined Under Namespace
Modules: Helper
Classes: Configuration, RequestError
Class Attribute Summary collapse
Class Method Summary
collapse
Class Attribute Details
.configuration ⇒ Object
Returns the value of attribute configuration.
13
14
15
|
# File 'lib/error_response.rb', line 13
def configuration
@configuration
end
|
Class Method Details
.all ⇒ Object
23
24
25
|
# File 'lib/error_response.rb', line 23
def all
yaml_hash
end
|
19
20
21
|
# File 'lib/error_response.rb', line 19
def configure(&block)
yield(configuration)
end
|
.to_api(key, message = nil) ⇒ Object
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/error_response.rb', line 32
def to_api(key, message=nil)
json = deep_dup(yaml_hash)
json = json[key.to_s] || { 'error_code' => 500_000, 'error_message' => key.to_s }
json['error_key'] = key.to_s
json['error_message'] += ": #{message}" unless message.nil?
{
status: parse_status(json['error_code']),
json: json
}
end
|
.to_hash(key) ⇒ Object
27
28
29
30
|
# File 'lib/error_response.rb', line 27
def to_hash(key)
return {} unless yaml_hash.key?(key.to_s)
yaml_hash[key.to_s].merge({ 'error_key' => key.to_s })
end
|