Sha256: bbc11e4437983375e0acdf08924a81f942445eab937b9ddda0a1e8805607252c

Contents?: true

Size: 987 Bytes

Versions: 2

Compression:

Stored size: 987 Bytes

Contents

module FbGraph
  module Connections
    module Comments
      def comments(options = {})
        comments = if options.blank?
          # Note:
          # "comments" is a connection, but included in fetched "post" object
          # this improves performance when rendering the stream with comments
          @_comments_
        else
          FbGraph::Collection.new(get(options.merge(:connection => 'comments')))
        end
        comments.map! do |comment|
          Comment.new(comment.delete(:id), comment)
        end
      end

      def comment!(options = {})
        comment = post(options.merge(:connection => 'comments'))
        Comment.new(comment.delete(:id), options.merge(comment))
      end

      # NOTE:
      # the context of getting likes is User, but the context of posting like is not user.
      # posting like is always in same context with comment!
      def like!(options = {})
        post(options.merge(:connection => 'likes'))
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fb_graph-0.1.0 lib/fb_graph/connections/comments.rb
fb_graph-0.0.8 lib/fb_graph/connections/comments.rb