Sha256: 6edf05c89a748e480bfe7ff518afc7057c1134696730419ad07a0c8ae0fc1970

Contents?: true

Size: 1.17 KB

Versions: 2

Compression:

Stored size: 1.17 KB

Contents

module FbGraph
  module OpenGraph
    class Action < Node
      include Connections::Comments
      include Connections::Likes

      attr_accessor :type, :application, :from, :objects, :start_time, :end_time, :publish_time
      attr_accessor :raw_attributes

      def initialize(identifier, attributes = {})
        super
        @raw_attributes = attributes
        @type = attributes[:type]
        if application = attributes[:application]
          @application = Application.new(application[:id], application)
        end
        if from = attributes[:from]
          @from = User.new(from[:id], from)
        end
        @objects = {}
        if attributes[:data]
          attributes[:data].each do |key, _attributes_|
            @objects[key] = Object.new _attributes_[:id], _attributes_
          end
        end
        @objects = @objects.with_indifferent_access
        [:start_time, :end_time, :publish_time].each do |key|
          self.send "#{key}=", Time.parse(attributes[key]) if attributes[key]
        end

        # cached connection
        @_likes_ = Collection.new(attributes[:likes])
        @_comments_ = Collection.new(attributes[:comments])
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fb_graph-2.2.0.alpha2 lib/fb_graph/open_graph/action.rb
fb_graph-2.2.0.alpha lib/fb_graph/open_graph/action.rb