Sha256: 645bf70bf24b98051c8e0dd7ce8d924fe71712124087956f0f3a906e056ef683

Contents?: true

Size: 1.22 KB

Versions: 1

Compression:

Stored size: 1.22 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 object
          # this improves performance when rendering the stream with comments
          @_comments_
        else
          self.connection(:comments, options)
        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

1 entries across 1 versions & 1 rubygems

Version Path
fb_graph-1.1.5 lib/fb_graph/connections/comments.rb