Sha256: 7410151364ba67f81a23e6a70a73a3623d1721c837337a3a1a62f15f61cc80c9

Contents?: true

Size: 1.26 KB

Versions: 3

Compression:

Stored size: 1.26 KB

Contents

module Socialite
  module ApiWrappers
    module Facebook
      extend ActiveSupport::Concern

      included do
        require 'koala'
      end

      module ClassMethods
        def lookup(unique_id, options={})
          options.reverse_merge!({:access_token => nil})
          api_connection(options[:access_token]).get_object(unique_id)
        end

        def api_connection(access_token=nil)
          Koala::Facebook::API.new(access_token)
        end
      end

      module InstanceMethods
        def account_url
          "http://facebook.com/#{login}"
        end

        def access_token
          raise unless super
        end

        def api
          api_connection
        end

        def checkins
          api.get_connections(unique_id, 'checkins')
        end

        def friends
          api.get_connections(unique_id, 'friends')
        end

        def login
          raise unless super
        end

        def picture
          api.get_picture(unique_id)
        end

        def info
          api.get_object(unique_id)
        end

        def unique_id
          raise unless super
        end

      protected

        def api_connection
          @api_connection ||= self.class.api_connection(access_token)
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
socialite-0.0.1.beta4 lib/socialite/api_wrappers/facebook.rb
socialite-0.0.1.beta2 lib/socialite/api_wrappers/facebook.rb
socialite-0.0.1.beta lib/socialite/api_wrappers/facebook.rb