Skip to content
Snippets Groups Projects
Commit 3ebb899e authored by rswindell's avatar rswindell
Browse files

Created the following User class methods to allow the atomic (safe) adjustment

of numeric/statistical user fields:

* User.adjust_credits(count)
* User.adjust_minutes(count)
* User.posted_message([count=1])
* User.sent_email([count=1] [,feedback=false])
* User.uploaded_file(bytes [,files=1])
* User.downloaded_file(bytes [,files=1])

In the methods where "count" is optional (in square brackets), the default
value is '1'. So to increment the user's messages-posted statistcs by one
(for today and total), User.posted_message() is all that is needed.
Specifying a negative value allows adjust downwards (subtraction).
e.g. to remove 1000 credits: User.adjust_credits(-1000);

The User.stats properties are *intentionally* read-only (i.e. not a bug) since
there is no "safe" way to modify these properties using normal mathematical
operators (e.g. +=), hence the need for these new methods.
parent c5e084b8
No related branches found
No related tags found
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment