Class: FacebookDialog::Dialog
- Inherits:
-
Object
- Object
- FacebookDialog::Dialog
- Includes:
- ActiveModel::Serializers::JSON
- Defined in:
- lib/facebook_dialog/dialog.rb
Constant Summary collapse
- HTML_ONLY_KEYS =
[:redirect_uri, :display]
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Dialog
constructor
A new instance of Dialog.
- #query ⇒ Object
- #serializable_hash(options = {}) ⇒ Object
- #to_h ⇒ Object
- #url ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Dialog
Returns a new instance of Dialog.
11 12 13 14 |
# File 'lib/facebook_dialog/dialog.rb', line 11 def initialize( = {}) @options = @options[:app_id] = FacebookDialog.api_key end |
Class Method Details
.base_uri ⇒ Object
16 17 18 19 |
# File 'lib/facebook_dialog/dialog.rb', line 16 def self.base_uri raise ResourceNameNotDefined if resource_name.nil? "http://www.facebook.com/dialog/#{resource_name}/" end |
Instance Method Details
#query ⇒ Object
25 26 27 28 29 30 |
# File 'lib/facebook_dialog/dialog.rb', line 25 def query to_h.merge({ redirect_uri: @options[:redirect_uri] || @options[:link], display: @options[:display] || "popup" }) end |
#serializable_hash(options = {}) ⇒ Object
32 33 34 |
# File 'lib/facebook_dialog/dialog.rb', line 32 def serializable_hash( = {}) to_h.merge({method: self.class.resource_name}) end |
#to_h ⇒ Object
37 38 39 40 41 42 |
# File 'lib/facebook_dialog/dialog.rb', line 37 def to_h = @options.merge(self.class.defaults) = .reject{|key, value| HTML_ONLY_KEYS.include?(key) } () end |
#url ⇒ Object
21 22 23 |
# File 'lib/facebook_dialog/dialog.rb', line 21 def url "#{self.class.base_uri}?#{Rack::Utils.build_query(query)}" end |