Class: Halchemy::Metadata
- Inherits:
-
Object
- Object
- Halchemy::Metadata
- Defined in:
- lib/halchemy/metadata.rb
Overview
Allows a Resource to act first as a Hash, by keeping all HTTP related info in resource._halchemy
Instance Attribute Summary collapse
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#request ⇒ Object
readonly
Returns the value of attribute request.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Instance Method Summary collapse
-
#initialize(request, response, error) ⇒ Metadata
constructor
A new instance of Metadata.
- #raise_for_status_codes(settings = ">399") ⇒ Object
Constructor Details
#initialize(request, response, error) ⇒ Metadata
Returns a new instance of Metadata.
8 9 10 11 12 |
# File 'lib/halchemy/metadata.rb', line 8 def initialize(request, response, error) @request = request @response = response @error = error end |
Instance Attribute Details
#error ⇒ Object (readonly)
Returns the value of attribute error.
6 7 8 |
# File 'lib/halchemy/metadata.rb', line 6 def error @error end |
#request ⇒ Object (readonly)
Returns the value of attribute request.
6 7 8 |
# File 'lib/halchemy/metadata.rb', line 6 def request @request end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
6 7 8 |
# File 'lib/halchemy/metadata.rb', line 6 def response @response end |
Instance Method Details
#raise_for_status_codes(settings = ">399") ⇒ Object
14 15 16 17 18 |
# File 'lib/halchemy/metadata.rb', line 14 def raise_for_status_codes(settings = ">399") return unless settings_include_status_code?(settings, @response.status_code) raise HttpError, "Status code #{@response.status_code} matches \"#{settings}\"" end |