Class: Zizq::Resources::Resource
- Inherits:
-
Object
- Object
- Zizq::Resources::Resource
- Defined in:
- lib/zizq/resources/resource.rb
Overview
Base class for all typed response wrappers. Holds a reference to the Client (for following links) and the raw response hash.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the client instance that returned this resource.
Instance Method Summary collapse
-
#initialize(client, data) ⇒ Resource
constructor
A new instance of Resource.
-
#inspect ⇒ Object
Omit the client from inspect output to reduce noise.
-
#to_h ⇒ Object
Returns the underlying raw response hash.
Constructor Details
#initialize(client, data) ⇒ Resource
Returns a new instance of Resource.
18 19 20 21 |
# File 'lib/zizq/resources/resource.rb', line 18 def initialize(client, data) @client = client @data = data end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the client instance that returned this resource.
13 14 15 |
# File 'lib/zizq/resources/resource.rb', line 13 def client @client end |
Instance Method Details
#inspect ⇒ Object
Omit the client from inspect output to reduce noise.
29 30 31 32 33 34 35 |
# File 'lib/zizq/resources/resource.rb', line 29 def inspect #: () -> String ivars = instance_variables .reject { |v| v == :@client } .map { |v| " #{v}=#{instance_variable_get(v).inspect}" } .join "#<#{self.class}#{ivars}>" end |
#to_h ⇒ Object
Returns the underlying raw response hash.
24 25 26 |
# File 'lib/zizq/resources/resource.rb', line 24 def to_h #: () -> Hash[String, untyped] @data end |