Class: GSGraph::UserAchievement

Inherits:
Node
  • Object
show all
Includes:
Connections::Comments, Connections::Likes, Connections::Likes::Likable
Defined in:
lib/gs_graph/user_achievement.rb

Instance Attribute Summary collapse

Attributes inherited from Node

#access_token, #endpoint, #identifier, #raw_attributes

Instance Method Summary collapse

Methods included from Connections::Likes::Likable

#like!, #unlike!

Methods included from Connections::Likes

#likes

Methods included from Connections::Comments

#comment!, #comments

Methods inherited from Node

#connection, fetch, #fetch, #update

Methods included from Comparison

#==

Constructor Details

#initialize(identifier, attributes = {}) ⇒ UserAchievement

Returns a new instance of UserAchievement.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/gs_graph/user_achievement.rb', line 9

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

Instance Attribute Details

#achievementObject

Returns the value of attribute achievement.



7
8
9
# File 'lib/gs_graph/user_achievement.rb', line 7

def achievement
  @achievement
end

#applicationObject

Returns the value of attribute application.



7
8
9
# File 'lib/gs_graph/user_achievement.rb', line 7

def application
  @application
end

#created_timeObject

Returns the value of attribute created_time.



7
8
9
# File 'lib/gs_graph/user_achievement.rb', line 7

def created_time
  @created_time
end

#fromObject

Returns the value of attribute from.



7
8
9
# File 'lib/gs_graph/user_achievement.rb', line 7

def from
  @from
end

Instance Method Details

#destroy(options = {}) ⇒ Object



30
31
32
33
# File 'lib/gs_graph/user_achievement.rb', line 30

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