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.



19
20
21
22
23
24
25
26
27
# File 'lib/facebook_client.rb', line 19

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



41
42
43
44
45
46
47
# File 'lib/facebook_client.rb', line 41

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.



17
18
19
# File 'lib/facebook_client.rb', line 17

def params
  @params
end

Instance Method Details

#authObject



29
30
31
# File 'lib/facebook_client.rb', line 29

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

#graph(token, expires = nil) ⇒ Object



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

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

#rest_apiObject



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

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