Class: FacebookClient::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/facebook_client.rb

Constant Summary collapse

GRAPH_URL =
'https://graph.facebook.com'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(default_params = {}) ⇒ Base

Returns a new instance of Base.



22
23
24
25
26
27
28
29
30
# File 'lib/facebook_client.rb', line 22

def initialize(default_params={})
  @params = default_params.reverse_merge({
    :app_id       => ENV['FB_APP_ID'],
    :api_key      => ENV['FB_API_KEY'],
    :secret       => ENV['FB_SECRET'],
    :canvas       => ENV['FB_CANVAS'],
    :callback_url => ENV['FB_CALLBACK_URL']
  })
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object



44
45
46
47
48
49
50
# File 'lib/facebook_client.rb', line 44

def method_missing(name, *args)
  if @params.has_key?(name)
    return @params[name]
  else
    super
  end
end

Instance Attribute Details

#paramsObject (readonly)

Returns the value of attribute params.



20
21
22
# File 'lib/facebook_client.rb', line 20

def params
  @params
end

Instance Method Details

#authObject



32
33
34
# File 'lib/facebook_client.rb', line 32

def auth
  @auth ||= Auth.new(self)
end

#graph(token, expires = nil) ⇒ Object



36
37
38
# File 'lib/facebook_client.rb', line 36

def graph(token, expires = nil)
  Graph.new(self, token, expires)
end

#rest_apiObject



40
41
42
# File 'lib/facebook_client.rb', line 40

def rest_api
  @rest_api ||= RestApi.new(self)
end