Class: ServiceTemplate::JsonError
- Inherits:
-
Object
- Object
- ServiceTemplate::JsonError
- Defined in:
- lib/service_template/json_error.rb
Instance Method Summary collapse
-
#initialize(code, detail) ⇒ JsonError
constructor
A new instance of JsonError.
- #to_h ⇒ Object
- #to_json(options = {}) ⇒ Object
Constructor Details
#initialize(code, detail) ⇒ JsonError
Returns a new instance of JsonError.
3 4 5 6 |
# File 'lib/service_template/json_error.rb', line 3 def initialize(code, detail) @code = code @detail = detail end |
Instance Method Details
#to_h ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/service_template/json_error.rb', line 12 def to_h e = { error: { code: @code, detail: @detail } } end |
#to_json(options = {}) ⇒ Object
8 9 10 |
# File 'lib/service_template/json_error.rb', line 8 def to_json( = {}) to_h.to_json() end |