class Yt::Collections::Resources
@private
Public Instance Methods
Source
# File lib/yt/collections/resources.rb, line 8 def delete_all(params = {}) do_delete_all params end
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
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
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
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
Source
# File lib/yt/collections/resources.rb, line 52 def camelize(value) value.to_s.camelize(:lower).to_sym end
Source
# File lib/yt/collections/resources.rb, line 25 def resources_params {max_results: 50, part: 'snippet,status'} end
Source
# File lib/yt/collections/resources.rb, line 48 def should_include_part_in_insert?(part, attributes = {}) (part[:keys] & attributes.keys).any? end