Exception: ErrorsHelper::Base
- Inherits:
-
StandardError
- Object
- StandardError
- ErrorsHelper::Base
- Includes:
- ActiveModel::Serialization
- Defined in:
- lib/errors_helper/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
Instance Method Summary collapse
-
#initialize(message: ErrorsHelper.build_response(code: '99')[:message], code: ErrorsHelper.build_response(code: '99')[:code], status: nil) ⇒ Base
constructor
A new instance of Base.
- #inspect ⇒ Object
- #status ⇒ Object
- #to_hash ⇒ Object (also: #to_h)
Constructor Details
#initialize(message: ErrorsHelper.build_response(code: '99')[:message], code: ErrorsHelper.build_response(code: '99')[:code], status: nil) ⇒ Base
Returns a new instance of Base.
11 12 13 14 15 16 17 |
# File 'lib/errors_helper/base.rb', line 11 def initialize(message: ErrorsHelper.build_response(code: '99')[:message], code: ErrorsHelper.build_response(code: '99')[:code], status: nil) @message = @code = code @status = status end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
9 10 11 |
# File 'lib/errors_helper/base.rb', line 9 def code @code end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
9 10 11 |
# File 'lib/errors_helper/base.rb', line 9 def @message end |
Instance Method Details
#inspect ⇒ Object
32 33 34 |
# File 'lib/errors_helper/base.rb', line 32 def inspect "[Code: #{code}] #{}" end |
#status ⇒ Object
28 29 30 |
# File 'lib/errors_helper/base.rb', line 28 def status Rack::Utils::SYMBOL_TO_STATUS_CODE[@status] end |
#to_hash ⇒ Object Also known as: to_h
19 20 21 22 23 24 |
# File 'lib/errors_helper/base.rb', line 19 def to_hash { message: , code: code }.compact end |