module Yt::Actions::Insert

Private Instance Methods

do_insert(extra_insert_params = {}) click to toggle source
# File lib/yt/actions/insert.rb, line 12
def do_insert(extra_insert_params = {})
  response = insert_request(extra_insert_params).run
  @items = []
  new_item extract_data_from(response)
end
extract_data_from(response) click to toggle source
# File lib/yt/actions/insert.rb, line 37
def extract_data_from(response)
  response.body
end
insert_params() click to toggle source
# File lib/yt/actions/insert.rb, line 24
def insert_params
  path = "/youtube/v3/#{self.class.to_s.demodulize.camelize :lower}"

  {}.tap do |params|
    params[:path] = path
    params[:host] = 'www.googleapis.com'
    params[:method] = :post
    params[:auth] = @auth
    params[:expected_response] = Net::HTTPOK
    params[:api_key] = Yt.configuration.api_key if Yt.configuration.api_key
  end
end
insert_request(params = {}) click to toggle source
# File lib/yt/actions/insert.rb, line 18
def insert_request(params = {})
  Yt::Request.new(insert_params.deep_merge params).tap do |request|
    print "#{request.as_curl}\n" if Yt.configuration.developing?
  end
end