From bcd7baba2a91ae6ac75c046514b9fa420fb820f4 Mon Sep 17 00:00:00 2001 From: hellekin Date: Tue, 2 Feb 2021 23:26:54 +0100 Subject: 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. --- app/models/agent.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'app') 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 -- cgit v1.2.3