Sha256: 2f3bcb823c5e418a56880f74c5442b485de1b8ef23f31b892f7afb98b00348d7

Contents?: true

Size: 1.26 KB

Versions: 4

Compression:

Stored size: 1.26 KB

Contents

module FbGraph
  module Connections
    module Comments
      def comments(options = {})
        comments = if @_comments_.present? && 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.merge(
            :access_token => options[:access_token] || self.access_token
          ))
        end
      end

      def comment!(options = {})
        comment = post(options.merge(:connection => 'comments'))
        Comment.new(comment.delete(:id), options.merge(comment).merge(
          :access_token => options[:access_token] || self.access_token
        ))
      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

      def unlike!(options = {})
        destroy(options.merge(:connection => 'likes'))
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
fb_graph-0.4.2 lib/fb_graph/connections/comments.rb
fb_graph-0.4.1 lib/fb_graph/connections/comments.rb
fb_graph-0.4.0 lib/fb_graph/connections/comments.rb
fb_graph-0.3.0 lib/fb_graph/connections/comments.rb