class Yt::Collections::RelatedPlaylists
Private Instance Methods
Source
# File lib/yt/collections/related_playlists.rb, line 32 def eager_load_items_from(items) conditions = {id: items.values.join(','), part: 'snippet,status'} Collections::Playlists.new(auth: @auth).where conditions end
Since there are at most 5 related playlists, they can be eager-loaded.
Source
# File lib/yt/collections/related_playlists.rb, line 25 def extract_items(list) if (items = super).any? items.first['contentDetails'].fetch 'relatedPlaylists', {} end end
The related playlists are nested inside the “relatedPlaylists” key.
Calls superclass method
Source
# File lib/yt/collections/related_playlists.rb, line 10 def list_resources 'channels' end
Retrieving related playlists requires to hit the /channels endpoint.
Source
# File lib/yt/collections/related_playlists.rb, line 38 def new_item(playlist) playlist end
Related playlists are eager-loaded, there’s no need to load them again.
Source
# File lib/yt/collections/related_playlists.rb, line 15 def playlists_params {part: 'contentDetails', id: @parent.id} end
The related playlists are included in the content details of a channel.
Source
# File lib/yt/collections/related_playlists.rb, line 20 def resource_class Yt::Models::Playlist end
The object to create is “Yt::Models::Playlist”, not “RelatedPlaylist”