class Yt::Collections::Resources

@private

Public Instance Methods

delete_all(params = {}) click to toggle source
# File lib/yt/collections/resources.rb, line 8
def delete_all(params = {})
  do_delete_all params
end
insert(attributes = {}, options = {}) click to toggle source
# File lib/yt/collections/resources.rb, line 12
def insert(attributes = {}, options = {}) #
  underscore_keys! attributes
  body = build_insert_body attributes
  params = {part: body.keys.join(',')}
  do_insert(params: params, body: body)
end

Private Instance Methods

attributes_for_new_item(data) click to toggle source
# File lib/yt/collections/resources.rb, line 21
def attributes_for_new_item(data)
  {id: data['id'], snippet: data['snippet'], status: data['status'], auth: @auth}
end
build_insert_body(attributes = {}) click to toggle source
# File lib/yt/collections/resources.rb, line 29
def build_insert_body(attributes = {})
  {}.tap do |body|
    insert_parts.each do |name, part|
      if should_include_part_in_insert? part, attributes
        body[name] = build_insert_body_part part, attributes
        sanitize_brackets! body[name] if part[:sanitize_brackets]
      end
    end
  end
end
build_insert_body_part(part, attributes = {}) click to toggle source
# File lib/yt/collections/resources.rb, line 40
def build_insert_body_part(part, attributes = {})
  {}.tap do |body_part|
    part[:keys].map do |key|
      body_part[camelize key] = attributes[key] if attributes[key]
    end
  end
end
camelize(value) click to toggle source
# File lib/yt/collections/resources.rb, line 52
def camelize(value)
  value.to_s.camelize(:lower).to_sym
end
resources_params() click to toggle source
# File lib/yt/collections/resources.rb, line 25
def resources_params
  {max_results: 50, part: 'snippet,status'}
end
should_include_part_in_insert?(part, attributes = {}) click to toggle source
# File lib/yt/collections/resources.rb, line 48
def should_include_part_in_insert?(part, attributes = {})
  (part[:keys] & attributes.keys).any?
end