Class: Halchemy::Resource

Inherits:
Hash
  • Object
show all
Defined in:
lib/halchemy/resource.rb

Overview

The Resource class extends a Hash to include a metadata object containing details about the HTTP request and response. This lets the metadata stay “out of the way” allowing the client code to use the result of a request directly as a resource without losing access to the request details, response details, and any error details.

Direct Known Subclasses

HalResource

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#_halchemyObject

Returns the value of attribute _halchemy.



14
15
16
# File 'lib/halchemy/resource.rb', line 14

def _halchemy
  @_halchemy
end

Instance Method Details

#to_sObject



16
17
18
19
20
21
22
# File 'lib/halchemy/resource.rb', line 16

def to_s
  if !keys.empty?
    to_json
  else
    _halchemy&.response&.body.to_s
  end
end