Module: TheCity::API::Users
Instance Method Summary collapse
-
#me(options = {}) ⇒ TheCity::User
(also: #current_user)
Returns the user associated with the current access token.
-
#permissions(options = {}) ⇒ TheCity::Permissions
Returns the permissions for the current user.
-
#user(*args) ⇒ TheCity::User
The requested user.
-
#user?(user) ⇒ Boolean
Returns true if the specified user exists.
Instance Method Details
#me(options = {}) ⇒ TheCity::User Also known as: current_user
Returns the user associated with the current access token
36 37 38 39 |
# File 'lib/the_city/api/users.rb', line 36 def me(={}) @me = nil if .delete(:force_download) @me ||= object_from_response(TheCity::User, :get, "/me", , {:current_user => true, :client => self}) end |
#permissions(options = {}) ⇒ TheCity::Permissions
Returns the permissions for the current user
51 52 53 54 |
# File 'lib/the_city/api/users.rb', line 51 def (*args) arguments = TheCity::Arguments.new(args) object_from_response(TheCity::Permissions, :get, "/me/permissions", arguments.) end |
#user(id) ⇒ TheCity::User #user(id, options = {}) ⇒ TheCity::User
Returns The requested user.
19 20 21 22 23 24 25 |
# File 'lib/the_city/api/users.rb', line 19 def user(*args) @users ||= {} arguments = TheCity::Arguments.new(args) uid = args.shift @users[uid] = nil if arguments..delete(:force_download) @users[uid] ||= object_from_response(TheCity::User, :get, "/users/#{uid}", arguments., {:client => self}) end |
#user?(user) ⇒ Boolean
Returns true if the specified user exists
61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/the_city/api/users.rb', line 61 def user?(user) user_id = case user when ::Integer user when ::String user.to_i when TheCity::User user.id end get("/users/#{user_id}") true rescue TheCity::Error::NotFound false end |