aboutsummaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorhellekin <hellekin@cepheide.org>2021-02-02 23:26:54 +0100
committerhellekin <hellekin@cepheide.org>2021-02-02 23:26:54 +0100
commitbcd7baba2a91ae6ac75c046514b9fa420fb820f4 (patch)
tree9c05b49c3b76271f6665265cc6d7e02328addbd5 /app/models
parente11e9ada062b12b064dde124bb5601df7c40f45b (diff)
downloadincommon-map-bcd7baba2a91ae6ac75c046514b9fa420fb820f4.tar.gz
Add syntactic sugar
To some it may be more straightforward to think of the members of an Agent as "users". This commit accepts using `Agent#users` instead of `Agent#members`, but warns developers that they should be using the other method. Since Agent has_many Users, the Principle of Least Surprise warrants that `agent.users` does something. But they're really members.
Diffstat (limited to 'app/models')
-rw-r--r--app/models/agent.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/app/models/agent.rb b/app/models/agent.rb
index 28ba579..e44c6ec 100644
--- a/app/models/agent.rb
+++ b/app/models/agent.rb
@@ -17,4 +17,10 @@ class Agent < ApplicationRecord
def to_s
name
end
+
+ # Syntactic sugar -- but they're really members.
+ def users
+ Rails.logger.warn "Calling `Agent#users`! You should be using `Agent#members` instead."
+ members
+ end
end