Sha256: 894783c195f3b706cc95f019b46851364745a3ae07f5e0d4e82edef6235227fb

Contents?: true

Size: 935 Bytes

Versions: 50

Compression:

Stored size: 935 Bytes

Contents

module FbGraph
  class AdConnectionObject < Node
    attr_accessor :name, :url, :type, :tabs, :picture, :object

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

    def initialize(identifier, attributes = {})
      super

      %w(name url type tabs picture).each do |field|
        send("#{field}=", attributes[field.to_sym])
      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

50 entries across 50 versions & 1 rubygems

Version Path
fb_graph-2.2.0 lib/fb_graph/ad_connection_object.rb
fb_graph-2.2.0.beta lib/fb_graph/ad_connection_object.rb
fb_graph-2.2.0.alpha2 lib/fb_graph/ad_connection_object.rb
fb_graph-2.2.0.alpha lib/fb_graph/ad_connection_object.rb
fb_graph-2.1.13 lib/fb_graph/ad_connection_object.rb
fb_graph-2.1.12 lib/fb_graph/ad_connection_object.rb
fb_graph-2.1.11 lib/fb_graph/ad_connection_object.rb
fb_graph-2.1.10 lib/fb_graph/ad_connection_object.rb
fb_graph-2.1.9 lib/fb_graph/ad_connection_object.rb
fb_graph-2.1.8 lib/fb_graph/ad_connection_object.rb