class Yt::Collections::GroupItems

@private

Private Instance Methods

attributes_for_new_item(data) click to toggle source
# File lib/yt/collections/group_items.rb, line 11
def attributes_for_new_item(data)
  super(data).tap do |attributes|
    attributes[:video] = data['video']
  end
end
eager_load_items_from(items) click to toggle source
Calls superclass method Yt::Actions::List#eager_load_items_from
# File lib/yt/collections/group_items.rb, line 28
def eager_load_items_from(items)
  if included_relationships.include?(:video)
    all_video_ids = items.map{|item| item['resource']['id']}.uniq
    all_video_ids.each_slice(50) do |video_ids|
      conditions = {id: video_ids.join(',')}
      conditions[:part] = 'snippet,status,statistics,contentDetails'
      videos = Collections::Videos.new(auth: @auth).where conditions
      items.each do |item|
        video = videos.find{|v| v.id == item['resource']['id']}
        item['video'] = video if video
      end
    end
  end
  super
end
list_params() click to toggle source
Calls superclass method Yt::Actions::List#list_params
# File lib/yt/collections/group_items.rb, line 17
def list_params
  super.tap do |params|
    params[:host] = 'youtubeanalytics.googleapis.com'
    params[:path] = "/v2/groupItems"
    params[:params] = {group_id: @parent.id}
    if @auth.owner_name
      params[:params][:on_behalf_of_content_owner] = @auth.owner_name
    end
  end
end