Sha256: 1aada9304bfcd18255994cec69004546b449d34425cf5ca09d7396523712dde5

Contents?: true

Size: 1.11 KB

Versions: 3

Compression:

Stored size: 1.11 KB

Contents

module FbGraph
  module Connections
    module Comments
      def comments(options = {})
        comments = if @_comments_ && options.blank?
          self.connection(:comments, options.merge(:cached_collection => @_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

3 entries across 3 versions & 1 rubygems

Version Path
fb_graph-1.2.1 lib/fb_graph/connections/comments.rb
fb_graph-1.2.0 lib/fb_graph/connections/comments.rb
fb_graph-1.1.7 lib/fb_graph/connections/comments.rb