Sha256: 33f538c2ae8a4218063f2d69688780a16e3c6dbcef4eb755721e89a196b426cf

Contents?: true

Size: 1.12 KB

Versions: 7

Compression:

Stored size: 1.12 KB

Contents

module FbGraph2
  class Edge
    module Likes
      module LikerContext
        def likes(params = {})
          pages = self.edge :likes, params
          pages.collect do |page|
            Page.new(page[:id], page).authenticate self.access_token
          end
        end

        def liked?(page, params = {})
          pages = self.edge :likes, params, edge_scope: page
          pages.present?
        end
      end

      module LikeeContext
        def assign(attributes)
          super
          if attributes.include? :likes
            @_cached_likes = Collection.new attributes[:likes]
          end
        end

        def likes(params = {})
          users = if @_cached_likes.present? && params.blank?
            @_cached_likes
          else
            self.edge :likes, params
          end
          users.collect do |user|
            User.new(user[:id], user).authenticate self.access_token
          end
        end

        def like!(params = {})
          self.post params, edge: :likes
        end

        def unlike!(params = {})
          self.delete params, edge: :likes
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
fb_graph2-0.1.0 lib/fb_graph2/edge/likes.rb
fb_graph2-0.0.11 lib/fb_graph2/edge/likes.rb
fb_graph2-0.0.10 lib/fb_graph2/edge/likes.rb
fb_graph2-0.0.9 lib/fb_graph2/edge/likes.rb
fb_graph2-0.0.8 lib/fb_graph2/edge/likes.rb
fb_graph2-0.0.7 lib/fb_graph2/edge/likes.rb
fb_graph2-0.0.6 lib/fb_graph2/edge/likes.rb