Class: Spotify::SDK::Model

Inherits:
OpenStruct
  • Object
show all
Defined in:
lib/spotify/sdk/model.rb

Overview

For each SDK response object (i.e. Device), we have a Model class. We’re using OpenStruct.

Direct Known Subclasses

Connect::Device

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(payload, parent) ⇒ Model

Initialize a new Model instance.

Parameters:

  • hash (Hash)

    The response payload.

  • parent (Spotify::SDK)

    The SDK object for context.



15
16
17
18
19
20
21
22
23
# File 'lib/spotify/sdk/model.rb', line 15

def initialize(payload, parent)
  @payload = payload
  validate_payload

  @parent = parent
  validate_parent

  super(payload)
end

Instance Attribute Details

#parentObject (readonly)

A reference to Spotify::SDK::Connect, so we can also do stuff.



28
29
30
# File 'lib/spotify/sdk/model.rb', line 28

def parent
  @parent
end