Sha256: 491851a44e4e0cfeb009f272ae33c9d4c4dcc8b5afc238236405c0a9a3b1abf9

Contents?: true

Size: 1.27 KB

Versions: 41

Compression:

Stored size: 1.27 KB

Contents

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

      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] = case _attributes_
            when Hash
              Object.new _attributes_[:id], _attributes_
            else
              _attributes_
            end
          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
        cache_collections attributes, :comments, :likes
      end
    end
  end
end

Version data entries

41 entries across 41 versions & 1 rubygems

Version Path
fb_graph-2.7.17 lib/fb_graph/open_graph/action.rb
fb_graph-2.7.16 lib/fb_graph/open_graph/action.rb
fb_graph-2.7.15 lib/fb_graph/open_graph/action.rb
fb_graph-2.7.14 lib/fb_graph/open_graph/action.rb
fb_graph-2.7.13 lib/fb_graph/open_graph/action.rb
fb_graph-2.7.12 lib/fb_graph/open_graph/action.rb
fb_graph-2.7.11 lib/fb_graph/open_graph/action.rb
fb_graph-2.7.10 lib/fb_graph/open_graph/action.rb
fb_graph-2.7.9 lib/fb_graph/open_graph/action.rb
fb_graph-2.7.8 lib/fb_graph/open_graph/action.rb
fb_graph-2.7.7 lib/fb_graph/open_graph/action.rb
fb_graph-2.7.6 lib/fb_graph/open_graph/action.rb
fb_graph-2.7.5 lib/fb_graph/open_graph/action.rb
fb_graph-2.7.4 lib/fb_graph/open_graph/action.rb
fb_graph-2.7.3 lib/fb_graph/open_graph/action.rb
fb_graph-2.7.2 lib/fb_graph/open_graph/action.rb
fb_graph-2.7.1 lib/fb_graph/open_graph/action.rb
fb_graph-2.7.0 lib/fb_graph/open_graph/action.rb
fb_graph-2.6.7 lib/fb_graph/open_graph/action.rb
fb_graph-2.6.6 lib/fb_graph/open_graph/action.rb