Sha256: a6065337d3570130084d0881b438b5731dd88a3bce641aa81051e4583fefa1aa

Contents?: true

Size: 1.36 KB

Versions: 13

Compression:

Stored size: 1.36 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

13 entries across 13 versions & 1 rubygems

Version Path
fb_graph-2.7.5 lib/fb_graph/ad_connection_object.rb
fb_graph-2.7.4 lib/fb_graph/ad_connection_object.rb
fb_graph-2.7.3 lib/fb_graph/ad_connection_object.rb
fb_graph-2.7.2 lib/fb_graph/ad_connection_object.rb
fb_graph-2.7.1 lib/fb_graph/ad_connection_object.rb
fb_graph-2.7.0 lib/fb_graph/ad_connection_object.rb
fb_graph-2.6.7 lib/fb_graph/ad_connection_object.rb
fb_graph-2.6.6 lib/fb_graph/ad_connection_object.rb
fb_graph-2.6.5 lib/fb_graph/ad_connection_object.rb
fb_graph-2.6.4 lib/fb_graph/ad_connection_object.rb
fb_graph-2.6.3 lib/fb_graph/ad_connection_object.rb
fb_graph-2.6.2 lib/fb_graph/ad_connection_object.rb
fb_graph-2.6.1 lib/fb_graph/ad_connection_object.rb