Sha256: 4483dec45d637a4f946d469c6cfaafea696bc8a91d130b61be8993f9d1d1a4c8

Contents?: true

Size: 1.22 KB

Versions: 75

Compression:

Stored size: 1.22 KB

Contents

module FbGraph
  class Achievement < Node
    attr_accessor :type, :application, :title, :url, :description, :image, :images, :data, :updated_time, :context, :points, :display_order

    def initialize(identifier, attributes = {})
      super

      # TODO: Handle data, context in smarter way.
      [:type, :title, :url, :description, :data, :context].each do |key|
        send "#{key}=", attributes[key]
      end

      if self.data
        @points = self.data[:points]
      end

      if self.context
        @display_order = self.context[:display_order]
      end

      @images = []
      if _images_ = attributes[:image]
        _images_.each do |_image_|
          @images << _image_[:url]
        end
      end
      @image = @images.first

      if application = attributes[:application]
        application[:link] = application[:url] # for some reason, FB uses "url" only here..
        @application = Application.new(application[:id], application)
      end

      if attributes[:updated_time]
        @updated_time = Time.parse(attributes[:updated_time]).utc
      end
    end

    def destroy(options = {})
      options[:access_token] ||= self.access_token
      application.unregister_achievement!(url, options)
    end
  end
end

Version data entries

75 entries across 75 versions & 1 rubygems

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