Skip to content

Commit

Permalink
Fix bug in lib/apple_music
Browse files Browse the repository at this point in the history
  • Loading branch information
kumabook committed Jan 26, 2019
1 parent 53b2502 commit deb16a4
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
6 changes: 4 additions & 2 deletions lib/apple_music/album.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ class Album
genres
]
attr_accessor :id, :type, :href
attr_accessor *@attributes
attr_accessor *@relationships

class << self
attr_accessor :attributes
Expand All @@ -36,10 +38,10 @@ def initialize(id, type, href, attributes = {}, relationships = {})
@id = id
@type = type
@href = href
@@attributes.each do |attr|
self.class.attributes.each do |attr|
send("#{attr}=".to_sym, attributes[attr.to_s.camelize(:lower)])
end
@@relationships.each do |rel|
self.class.relationships.each do |rel|
relationship = relationships[rel.to_s.camelize(:lower)]
next if relationship.nil?
partial_resources = relationship["data"].map do |h|
Expand Down
6 changes: 4 additions & 2 deletions lib/apple_music/artist.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ class Artist
genres
]
attr_accessor :id, :type, :href
attr_accessor *@attributes
attr_accessor *@relationships

class << self
attr_accessor :attributes
Expand All @@ -25,10 +27,10 @@ def initialize(id, type, href, attributes = nil, relationships = nil)
@id = id
@type = type
@href = href
@@attributes.each do |attr|
self.class.attributes.each do |attr|
send("#{attr}=".to_sym, attributes[attr.to_s.camelize(:lower)])
end
@@relationships.each do |rel|
self.class.relationships.each do |rel|
relationship = relationships[rel.to_s.camelize(:lower)]
next if relationship.nil?
partial_resources = relationship["data"].map do |h|
Expand Down
6 changes: 4 additions & 2 deletions lib/apple_music/music_video.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ class MusicVideo
genres
]
attr_accessor :id, :type, :href
attr_accessor *@attributes
attr_accessor *@relationships

class << self
attr_accessor :attributes
Expand All @@ -39,10 +41,10 @@ def initialize(id, type, href, attributes = {}, relationships = {})
@id = id
@type = type
@href = href
@@attributes.each do |attr|
self.class.attributes.each do |attr|
send("#{attr}=".to_sym, attributes[attr.to_s.camelize(:lower)])
end
@@relationships.each do |rel|
self.class.relationships.each do |rel|
relationship = relationships[rel.to_s.camelize(:lower)]
next if relationship.nil?
partial_resources = relationship["data"].map do |h|
Expand Down
6 changes: 4 additions & 2 deletions lib/apple_music/song.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ class Song
genres
]
attr_accessor :id, :type, :href
attr_accessor *@attributes
attr_accessor *@relationships

class << self
attr_accessor :attributes
Expand All @@ -41,10 +43,10 @@ def initialize(id, type, href, attributes = {}, relationships = {})
@id = id
@type = type
@href = href
@@attributes.each do |attr|
self.class.attributes.each do |attr|
send("#{attr}=".to_sym, attributes[attr.to_s.camelize(:lower)])
end
@@relationships.each do |rel|
self.class.relationships.each do |rel|
relationship = relationships[rel.to_s.camelize(:lower)]
next if relationship.nil?
partial_resources = relationship["data"].map do |h|
Expand Down

0 comments on commit deb16a4

Please sign in to comment.