Module: HumanError::Error
- Included in:
- HumanError::Errors::AssociationError, HumanError::Errors::DuplicateAuthenticationError, HumanError::Errors::ForbiddenError, HumanError::Errors::InvalidTokenError, HumanError::Errors::InvalidUsernameOrPasswordError, HumanError::Errors::ParameterMissingError, HumanError::Errors::ResourceNotFoundError, HumanError::Errors::ResourcePersistenceError, HumanError::Errors::UnpermittedParametersError
- Defined in:
- lib/human_error/error.rb
Defined Under Namespace
Modules: ClassMethods
Instance Attribute Summary collapse
-
#code ⇒ Object
Returns the value of attribute code.
-
#detail ⇒ Object
Returns the value of attribute detail.
-
#developer_documentation_url ⇒ Object
Returns the value of attribute developer_documentation_url.
-
#external_documentation_url ⇒ Object
Returns the value of attribute external_documentation_url.
-
#http_status ⇒ Object
(also: #status)
Returns the value of attribute http_status.
-
#id ⇒ Object
Returns the value of attribute id.
-
#message ⇒ Object
Returns the value of attribute message.
-
#source ⇒ Object
Returns the value of attribute source.
-
#title ⇒ Object
Returns the value of attribute title.
Class Method Summary collapse
Instance Method Summary collapse
- #as_json(_options = {}) ⇒ Object
- #initialize(**args) ⇒ Object
- #to_json(_options = {}) ⇒ Object
- #to_s ⇒ Object
Instance Attribute Details
#code ⇒ Object
Returns the value of attribute code.
15 16 17 |
# File 'lib/human_error/error.rb', line 15 def code @code end |
#detail ⇒ Object
Returns the value of attribute detail.
15 16 17 |
# File 'lib/human_error/error.rb', line 15 def detail @detail end |
#developer_documentation_url ⇒ Object
Returns the value of attribute developer_documentation_url.
15 16 17 |
# File 'lib/human_error/error.rb', line 15 def developer_documentation_url @developer_documentation_url end |
#external_documentation_url ⇒ Object
Returns the value of attribute external_documentation_url.
15 16 17 |
# File 'lib/human_error/error.rb', line 15 def external_documentation_url @external_documentation_url end |
#http_status ⇒ Object Also known as: status
Returns the value of attribute http_status.
15 16 17 |
# File 'lib/human_error/error.rb', line 15 def http_status @http_status end |
#id ⇒ Object
Returns the value of attribute id.
15 16 17 |
# File 'lib/human_error/error.rb', line 15 def id @id end |
#message ⇒ Object
Returns the value of attribute message.
15 16 17 |
# File 'lib/human_error/error.rb', line 15 def @message end |
#source ⇒ Object
Returns the value of attribute source.
15 16 17 |
# File 'lib/human_error/error.rb', line 15 def source @source end |
#title ⇒ Object
Returns the value of attribute title.
15 16 17 |
# File 'lib/human_error/error.rb', line 15 def title @title end |
Class Method Details
.included(base) ⇒ Object
99 100 101 |
# File 'lib/human_error/error.rb', line 99 def self.included(base) base.extend ClassMethods end |
Instance Method Details
#as_json(_options = {}) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/human_error/error.rb', line 31 def as_json( = {}) { errors: [ { id: id, links: { about: external_documentation_url, documentation: developer_documentation_url, }, status: http_status, code: code, title: title, detail: detail, source: source, }, ], } end |
#initialize(**args) ⇒ Object
25 26 27 28 29 |
# File 'lib/human_error/error.rb', line 25 def initialize(**args) args.each do |variable, value| public_send("#{variable}=", value) end end |
#to_json(_options = {}) ⇒ Object
50 51 52 |
# File 'lib/human_error/error.rb', line 50 def to_json( = {}) JSON.dump(as_json) end |
#to_s ⇒ Object
95 96 97 |
# File 'lib/human_error/error.rb', line 95 def to_s @message || detail end |