Class: Kippt::Comments

Inherits:
Object
  • Object
show all
Includes:
CollectionResource
Defined in:
lib/kippt/comments.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from CollectionResource

#create, #destroy_resource, #save_resource

Methods included from ReadCollectionResource

#[], #collection_from_url

Constructor Details

#initialize(client, clip) ⇒ Comments

Returns a new instance of Comments.



9
10
11
12
# File 'lib/kippt/comments.rb', line 9

def initialize(client, clip)
  @client = client
  @clip   = clip
end

Instance Attribute Details

#clipObject (readonly)

Returns the value of attribute clip.



7
8
9
# File 'lib/kippt/comments.rb', line 7

def clip
  @clip
end

Class Method Details

.valid_filter_parametersObject



14
15
16
# File 'lib/kippt/comments.rb', line 14

def self.valid_filter_parameters
  [:limit, :offset]
end

Instance Method Details

#base_uriObject



26
27
28
# File 'lib/kippt/comments.rb', line 26

def base_uri
  "clips/#{clip.id}/comments"
end

#build(attributes = {}) ⇒ Object



42
43
44
# File 'lib/kippt/comments.rb', line 42

def build(attributes = {})
  object_class.new(attributes, client, clip)
end

#collection_classObject



22
23
24
# File 'lib/kippt/comments.rb', line 22

def collection_class
  Kippt::CommentCollection
end

#fetch(options = {}) ⇒ Object Also known as: all



30
31
32
33
34
35
36
37
38
# File 'lib/kippt/comments.rb', line 30

def fetch(options = {})
  validate_collection_options(options)

  if options.empty? && @clip.all_comments_embedded?
    collection_class.new({"objects" => @clip.comments_data}, client)
  else
    collection_class.new(client.get(base_uri, options).body, client)
  end
end

#object_classObject



18
19
20
# File 'lib/kippt/comments.rb', line 18

def object_class
  Kippt::Comment
end