Class Sawyer::Resource
In: lib/sawyer/resource.rb
Parent: Object

Methods

Included Modules

Enumerable

Constants

SPECIAL_METHODS = Set.new(%w(agent rels fields))
ATTR_SETTER = '='.freeze
ATTR_PREDICATE = '?'.freeze

Attributes

_agent  [R] 
_fields  [R] 
_rels  [R] 
attrs  [R] 

Public Class methods

Wire up accessor methods to pull from attrs

Initializes a Resource with the given data.

agent - The Sawyer::Agent that made the API request. data - Hash of key/value properties.

Public Instance methods

Allow fields to be retrieved via Hash notation

method - key name

Returns the value from attrs if exists

Allow fields to be set via Hash notation

method - key name value - value to set for the attr key

Returns - value

Checks to see if the given key is in this resource.

key - A Symbol key.

Returns true if the key exists, or false.

Provides access to a resource‘s attributes.

Processes an individual value of this resource. Hashes get exploded into another Resource, and Arrays get their values processed too.

value - An Object value of a Resource‘s data.

Returns an Object to set as the value of a Resource key.

to_h()

Alias for to_attrs

to_hash()

Alias for to_attrs

[Validate]