Sha256: ca94e33ae939ac1ba246b0e75a664e9de670b91ae875c100a6e250edee00868b

Contents?: true

Size: 1.22 KB

Versions: 21

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 "post" 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

21 entries across 21 versions & 2 rubygems

Version Path
fb_graph-1.1.4 lib/fb_graph/connections/comments.rb
fb_graph-1.1.3 lib/fb_graph/connections/comments.rb
fb_graph-1.1.2 lib/fb_graph/connections/comments.rb
fb_graph-1.1.1 lib/fb_graph/connections/comments.rb
fb_graph-1.1.0 lib/fb_graph/connections/comments.rb
fb_graph-1.0.7 lib/fb_graph/connections/comments.rb
fb_graph-1.0.6 lib/fb_graph/connections/comments.rb
fb_graph-1.0.5 lib/fb_graph/connections/comments.rb
palidanx-fb_graph-1.0.4 lib/fb_graph/connections/comments.rb
fb_graph-1.0.4 lib/fb_graph/connections/comments.rb
fb_graph-1.0.3 lib/fb_graph/connections/comments.rb
fb_graph-1.0.2 lib/fb_graph/connections/comments.rb
fb_graph-1.0.1 lib/fb_graph/connections/comments.rb
fb_graph-1.0.0 lib/fb_graph/connections/comments.rb
fb_graph-0.8.0 lib/fb_graph/connections/comments.rb
fb_graph-0.7.3 lib/fb_graph/connections/comments.rb
fb_graph-0.7.2 lib/fb_graph/connections/comments.rb
fb_graph-0.7.1 lib/fb_graph/connections/comments.rb
fb_graph-0.7.0 lib/fb_graph/connections/comments.rb
fb_graph-0.6.0 lib/fb_graph/connections/comments.rb