class ALD::API::User

A user registered on an ALD server.

Public

↑ top

Public Instance Methods

id() click to toggle source

Get the user's ID.

Returns

Returns a 32-character string containing the user's GUID.

Signature

# File lib/ALD/user.rb, line 16
                                                                                                                                                                                                                                                                                                                                   
joined() click to toggle source

Get the user's registration date. This method might trigger a HTTP request.

Returns

Returns a DateTime containing the date and time of the user's registration on the ALD server.

Signature

# File lib/ALD/user.rb, line 34
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
mailMD5() click to toggle source

Get the MD5 hash of the user's mail adress. This method might trigger a HTTP request.

Returns

Returns a String with the hashed mail adress.

# File lib/ALD/user.rb, line 60
def mailMD5
  request unless initialized?
  @data['mail-md5']
end
name() click to toggle source

Get the user's name

Returns

Returns a String containing the user's name.

Signature

# File lib/ALD/user.rb, line 24
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
privileges() click to toggle source

Get the user's privileges on the ALD server. This method might trigger a HTTP request.

Returns

Returns an Array of Symbols representing privileges the user has.

Signature

# File lib/ALD/user.rb, line 43
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

Internal

↑ top

Public Class Methods

new(api, data, initialized = false) click to toggle source

Create a new instance. This method is called by ALD::API#user and should not be called by library consumers.

api

The ALD::API instance this user belongs to

data

a Hash containing the user's data

initialized

a Boolean indicating whether the given data is complete or further API requests are necessary.

Calls superclass method ALD::API::CollectionEntry.new
# File lib/ALD/user.rb, line 50
def initialize(api, data, initialized = false)
  super(api, data, initialized)
end

Private Class Methods

initialized_attributes() click to toggle source

Override of CollectionEntry#initialized_attributes to enable automatic method definition, in this case #id and #name.

Returns

Returns an Array of attribute names (String)

# File lib/ALD/user.rb, line 81
def self.initialized_attributes
  %w[id name]
end
requested_attributes() click to toggle source

Override of CollectionEntry#requested_attributes to enable automatic method definition, in this case #joined and #privileges.

Returns

Returns an Array of attribute names (String)

# File lib/ALD/user.rb, line 89
def self.requested_attributes
  %w[joined privileges]
end

Private Instance Methods

request() click to toggle source

If the data given to the constructor was not complete, use the API to request further information from the server.

Returns

Returns nothing.

# File lib/ALD/user.rb, line 71
def request
  @data = @api.request("/users/#{id}")
  @data['privileges'].map!(&:to_sym)
  @data['joined'] = DateTime.parse(@data['joined'])
end