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.7.17 lib/fb_graph/user_achievement.rb
fb_graph-2.7.16 lib/fb_graph/user_achievement.rb
fb_graph-2.7.15 lib/fb_graph/user_achievement.rb
fb_graph-2.7.14 lib/fb_graph/user_achievement.rb
fb_graph-2.7.13 lib/fb_graph/user_achievement.rb
fb_graph-2.7.12 lib/fb_graph/user_achievement.rb
fb_graph-2.7.11 lib/fb_graph/user_achievement.rb
fb_graph-2.7.10 lib/fb_graph/user_achievement.rb
fb_graph-2.7.9 lib/fb_graph/user_achievement.rb
fb_graph-2.7.8 lib/fb_graph/user_achievement.rb
fb_graph-2.7.7 lib/fb_graph/user_achievement.rb
fb_graph-2.7.6 lib/fb_graph/user_achievement.rb
fb_graph-2.7.5 lib/fb_graph/user_achievement.rb
fb_graph-2.7.4 lib/fb_graph/user_achievement.rb
fb_graph-2.7.3 lib/fb_graph/user_achievement.rb
fb_graph-2.7.2 lib/fb_graph/user_achievement.rb
fb_graph-2.7.1 lib/fb_graph/user_achievement.rb
fb_graph-2.7.0 lib/fb_graph/user_achievement.rb
fb_graph-2.6.7 lib/fb_graph/user_achievement.rb
fb_graph-2.6.6 lib/fb_graph/user_achievement.rb