Module: GSGraph::Connections::UserAchievements

Included in:
User
Defined in:
lib/gs_graph/connections/user_achievements.rb

Instance Method Summary collapse

Instance Method Details

#achieve!(achievement_url, options = {}) ⇒ Object



12
13
14
15
# File 'lib/gs_graph/connections/user_achievements.rb', line 12

def achieve!(achievement_url, options = {})
  achievement = post options.merge(:connection => :achievements, :achievement => achievement_url)
  UserAchievement.new achievement[:id], achievement
end

#achievements(options = {}) ⇒ Object



4
5
6
7
8
9
10
# File 'lib/gs_graph/connections/user_achievements.rb', line 4

def achievements(options = {})
  options[:access_token] ||= self.access_token
  achievements = self.connection :achievements, options
  achievements.map! do |achievement|
    UserAchievement.new achievement[:id], achievement.merge(:access_token => options[:access_token])
  end
end

#unachieve!(achievement_url, options = {}) ⇒ Object



17
18
19
# File 'lib/gs_graph/connections/user_achievements.rb', line 17

def unachieve!(achievement_url, options = {})
  delete options.merge(:connection => :achievements, :achievement => achievement_url)
end