class ALD::API::User
Public: A user registered on an ALD
server.
Public Class Methods
Internal: Create a new instance. This method is called by 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.
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
Internal: Override of CollectionEntry#initialized_attributes to enable automatic method definition, in this case id and name.
Returns an Array of attribute names (String)
# File lib/ALD/user.rb, line 81 def self.initialized_attributes %w[id name] end
Internal: Override of CollectionEntry#requested_attributes to enable automatic method definition, in this case joined and privileges.
Returns an Array of attribute names (String)
# File lib/ALD/user.rb, line 89 def self.requested_attributes %w[joined privileges] end
Public Instance Methods
Public: Get the MD5 hash of the user’s mail adress. This method might trigger a HTTP request.
Returns a String with the hashed mail adress.
# File lib/ALD/user.rb, line 60 def mailMD5 request unless initialized? @data['mail-md5'] end
Private Instance Methods
Internal: If the data given to the constructor was not complete, use the API
to request further information from the server.
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