Sha256: acda236e714d7411cadce18d61e92a0ea37ef4dd705aa7a7bd8da0a92fcf7d5e

Contents?: true

Size: 1.07 KB

Versions: 63

Compression:

Stored size: 1.07 KB

Contents

module FbGraph
  class UserAchievement < Node
    include Connections::Comments
    include Connections::Likes
    include Connections::Likes::Likable

    attr_accessor :from, :created_time, :application, :achievement

    def initialize(identifier, attributes = {})
      super

      if from = attributes[:from]
        @from = User.new(from[:id], from)
      end
      if created_time = attributes[:created_time] || attributes[:publish_time]
        @created_time = Time.parse(created_time).utc
      end
      if application = attributes[:application]
        application[:link] = application[:url] # for some reason, FB uses "url" only here..
        @application = Application.new(application[:id], application)
      end
      if achievement = attributes[:achievement]
        @achievement = Achievement.new(achievement[:id], achievement)
      end

      # cached connection
      cache_collections attributes, :comments, :likes
    end

    def destroy(options = {})
      options[:access_token] ||= self.access_token
      from.unachieve!(achievement.url, options)
    end
  end
end

Version data entries

63 entries across 63 versions & 1 rubygems

Version Path
fb_graph-2.4.16 lib/fb_graph/user_achievement.rb
fb_graph-2.4.15 lib/fb_graph/user_achievement.rb
fb_graph-2.4.14 lib/fb_graph/user_achievement.rb
fb_graph-2.4.13 lib/fb_graph/user_achievement.rb
fb_graph-2.4.12 lib/fb_graph/user_achievement.rb
fb_graph-2.4.11 lib/fb_graph/user_achievement.rb
fb_graph-2.4.10 lib/fb_graph/user_achievement.rb
fb_graph-2.4.9 lib/fb_graph/user_achievement.rb
fb_graph-2.4.8 lib/fb_graph/user_achievement.rb
fb_graph-2.4.7 lib/fb_graph/user_achievement.rb
fb_graph-2.4.6 lib/fb_graph/user_achievement.rb
fb_graph-2.4.4 lib/fb_graph/user_achievement.rb
fb_graph-2.4.3 lib/fb_graph/user_achievement.rb
fb_graph-2.4.2 lib/fb_graph/user_achievement.rb
fb_graph-2.4.1 lib/fb_graph/user_achievement.rb
fb_graph-2.4.0 lib/fb_graph/user_achievement.rb
fb_graph-2.3.2 lib/fb_graph/user_achievement.rb
fb_graph-2.3.1 lib/fb_graph/user_achievement.rb
fb_graph-2.3.0 lib/fb_graph/user_achievement.rb
fb_graph-2.2.6 lib/fb_graph/user_achievement.rb