Class: Spotify::Models::ExternalURL

Inherits:
Object
  • Object
show all
Defined in:
lib/spotify/models/external_url.rb

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ ExternalURL

Sets the arguments to its variables.

Parameters:

  • args (Hash) (defaults to: {})

    the arguments that will be placed on each variable.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/spotify/models/external_url.rb', line 14

def initialize(args = {})
  args = Hash(args).with_indifferent_access

  hsh = {
    spotify: args[:spotify]
  }

  hsh = hsh.reject { |_, v| v.blank? }

  if hsh.present?
    # Generates the keys dynamically
    hsh.each do |k, v|
      key   = k
      value = v

      eval("@#{key} = value")
      class_eval { attr_reader key.to_sym }
    end
  end
end