Class: Facepalm::Config
- Inherits:
-
Object
- Object
- Facepalm::Config
- Defined in:
- lib/facepalm/config.rb
Overview
Facebook application configuration class
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
Class Method Summary collapse
-
.default ⇒ Object
A shortcut to access default configuration stored in RAILS_ROOT/config/facebook.yml.
- .load_default_config_from_file ⇒ Object
Instance Method Summary collapse
-
#api_client ⇒ Object
Koala Facebook API client instantiated with application access token.
-
#app_access_token ⇒ Object
Fetches application access token.
-
#callback_url(protocol) ⇒ Object
Application callback URL.
-
#canvas_page_url(protocol) ⇒ Object
URL of the application canvas page.
-
#initialize(options = {}) ⇒ Config
constructor
A new instance of Config.
- #oauth_client ⇒ Object
- #subscription_token ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Config
Returns a new instance of Config.
25 26 27 |
# File 'lib/facepalm/config.rb', line 25 def initialize( = {}) self.config = . end |
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
4 5 6 |
# File 'lib/facepalm/config.rb', line 4 def config @config end |
Class Method Details
.default ⇒ Object
A shortcut to access default configuration stored in RAILS_ROOT/config/facebook.yml
8 9 10 |
# File 'lib/facepalm/config.rb', line 8 def default @@default ||= self.new(load_default_config_from_file) end |
.load_default_config_from_file ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/facepalm/config.rb', line 12 def load_default_config_from_file config_data = YAML.load( ERB.new( File.read(::Rails.root.join("config", "facebook.yml")) ).result )[::Rails.env] raise NotConfigured.new("Unable to load configuration for #{ ::Rails.env } from config/facebook.yml") unless config_data config_data end |
Instance Method Details
#api_client ⇒ Object
Koala Facebook API client instantiated with application access token
43 44 45 |
# File 'lib/facepalm/config.rb', line 43 def api_client @api_client ||= Koala::Facebook::API.new(app_access_token) end |
#app_access_token ⇒ Object
Fetches application access token
48 49 50 |
# File 'lib/facepalm/config.rb', line 48 def app_access_token @app_access_token ||= oauth_client.get_app_access_token end |
#callback_url(protocol) ⇒ Object
Application callback URL
62 63 64 |
# File 'lib/facepalm/config.rb', line 62 def callback_url(protocol) protocol + callback_domain end |
#canvas_page_url(protocol) ⇒ Object
URL of the application canvas page
57 58 59 |
# File 'lib/facepalm/config.rb', line 57 def canvas_page_url(protocol) "#{ protocol }apps.facebook.com/#{ namespace }" end |
#oauth_client ⇒ Object
38 39 40 |
# File 'lib/facepalm/config.rb', line 38 def oauth_client @oauth_client ||= Koala::Facebook::OAuth.new(app_id, secret) end |
#subscription_token ⇒ Object
52 53 54 |
# File 'lib/facepalm/config.rb', line 52 def subscription_token Digest::MD5.hexdigest(secret) end |