Sha256: 97f28a7e37c8956703610961d71c06439db9e2a74736f61b6b1228fe487cc0b7

Contents?: true

Size: 1.34 KB

Versions: 12

Compression:

Stored size: 1.34 KB

Contents

module FbGraph
  class AdConnectionObject < Node
    attr_accessor :name, :url, :type, :tabs, :picture, :object, :is_game, :og_actions, :og_namespace, :og_objects, :supported_platforms

    TYPES = {
      :page => 1,
      :application => 2,
      :event => 3,
      :place => 6,
      :domain => 7
    }

    SUPPORTED_PLATFORM_TYPES = {
      :web => 1,
      :canvas => 2,
      :mobile_web => 3,
      :iphone => 4,
      :ipad => 5,
      :android => 6
    }

    def initialize(identifier, attributes = {})
      super

      %w(name url type tabs picture).each do |field|
        send("#{field}=", attributes[field.to_sym])
      end

      if self.type == TYPES[:application]
        %w(is_game og_actions og_namespace og_objects supported_platforms).each do |field|
          send("#{field}=", attributes[field.to_sym])
        end
      end

      self.object = if page?
        FbGraph::Page.new(identifier)
      elsif application?
        FbGraph::Application.new(identifier)
      elsif event?
        FbGraph::Event.new(identifier)
      elsif place?
        FbGraph::Place.new(identifier)
      elsif domain?
        FbGraph::Domain.new(identifier)
      end
    end

    # Defines methods for page?, application?, event? and so forth
    TYPES.keys.each do |object_type|
      define_method("#{object_type}?") { type == TYPES[object_type] }
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
fb_graph-2.7.17 lib/fb_graph/ad_connection_object.rb
fb_graph-2.7.16 lib/fb_graph/ad_connection_object.rb
fb_graph-2.7.15 lib/fb_graph/ad_connection_object.rb
fb_graph-2.7.14 lib/fb_graph/ad_connection_object.rb
fb_graph-2.7.13 lib/fb_graph/ad_connection_object.rb
fb_graph-2.7.12 lib/fb_graph/ad_connection_object.rb
fb_graph-2.7.11 lib/fb_graph/ad_connection_object.rb
fb_graph-2.7.10 lib/fb_graph/ad_connection_object.rb
fb_graph-2.7.9 lib/fb_graph/ad_connection_object.rb
fb_graph-2.7.8 lib/fb_graph/ad_connection_object.rb
fb_graph-2.7.7 lib/fb_graph/ad_connection_object.rb
fb_graph-2.7.6 lib/fb_graph/ad_connection_object.rb