Module: FbGraph2::Edge::Comments

Included in:
Achievement, Album, Comment, Milestone, Photo, Post, Video
Defined in:
lib/fb_graph2/edge/comments.rb

Instance Method Summary collapse

Instance Method Details

#assign(attributes) ⇒ Object



4
5
6
7
8
9
# File 'lib/fb_graph2/edge/comments.rb', line 4

def assign(attributes)
  super
  if attributes.include? :comments
    @_cached_comments = Collection.new attributes[:comments]
  end
end

#comment!(params = {}) ⇒ Object



22
23
24
25
# File 'lib/fb_graph2/edge/comments.rb', line 22

def comment!(params = {})
  comment = self.post params, edge: :comments
  Comment.new(comment[:id], params.merge(comment)).authenticate self.access_token
end

#comments(params = {}) ⇒ Object



11
12
13
14
15
16
17
18
19
20
# File 'lib/fb_graph2/edge/comments.rb', line 11

def comments(params = {})
  comments = if @_cached_comments.present? && params.blank?
    @_cached_comments
  else
    self.edge :comments, params
  end
  comments.collect! do |comment|
    Comment.new(comment[:id], comment).authenticate self.access_token
  end
end