lib/itunes_api/requests/lookup.rb in itunes_api-0.6.0 vs lib/itunes_api/requests/lookup.rb in itunes_api-0.7.0
- old
+ new
@@ -11,10 +11,12 @@
def self.artist_with_albums(id)
new(id).artist_with_albums
end
def artist_with_albums
+ return artist unless artist
+
artist.merge(albums: albums)
end
private
@@ -31,31 +33,32 @@
def albums_data
results.find_all { |wrappers| wrappers['wrapperType'] == 'collection' }
end
def artist
+ return artist_data unless artist_data
+
symbolize_keys(unwrapped(artist_data))
end
def artist_data
- results.find do |wrappers|
+ @artist_data ||= results.find do |wrappers|
wrappers['wrapperType'] == 'artist'
end
end
def query
{
entity: 'album',
- amgArtistId: @artist_id,
+ id: @artist_id,
country: country_code,
limit: LIMIT,
sort: 'recent'
}
end
- def unwrapped(hash)
- hash.delete('wrapperType')
- hash
+ def unwrapped(data_hash)
+ data_hash.tap { |hash| hash.delete('wrapperType') }
end
end
end
end