Class: Spotify::Models::ExternalID
- Inherits:
-
Object
- Object
- Spotify::Models::ExternalID
- Defined in:
- lib/spotify/models/external_id.rb
Instance Method Summary collapse
-
#initialize(args = {}) ⇒ ExternalID
constructor
Sets the arguments to its variables.
Constructor Details
#initialize(args = {}) ⇒ ExternalID
Sets the arguments to its variables.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/spotify/models/external_id.rb', line 14 def initialize(args = {}) args = Hash(args).with_indifferent_access hsh = { isrc: args[:isrc], ean: args[:ean], upc: args[:upc] } 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 |