Exception: OMCMS::Response::Error
- Inherits:
-
StandardError
- Object
- StandardError
- OMCMS::Response::Error
- Defined in:
- lib/omcms/response/error.rb
Instance Attribute Summary collapse
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
-
#initialize(response) ⇒ Error
constructor
A new instance of Error.
- #to_json(*_args) ⇒ Object
Constructor Details
#initialize(response) ⇒ Error
Returns a new instance of Error.
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/omcms/response/error.rb', line 8 def initialize(response) super return unless response response = add_body_to_error(response) unless response.respond_to? :body response.body.each do |key, value| instance_variable_set("@#{key}", value) self.class.send(:attr_reader, key) end end |
Instance Attribute Details
#status ⇒ Object (readonly)
Returns the value of attribute status.
6 7 8 |
# File 'lib/omcms/response/error.rb', line 6 def status @status end |
Instance Method Details
#to_json(*_args) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/omcms/response/error.rb', line 20 def to_json(*_args) instance_variables.to_h do |attribute| key = attribute.to_s.gsub("@", "") [snakecase(key), instance_variable_get(attribute)] end end |