ruby / rails boolean method naming conventions
- by Dennis
I have a short question on ruby / rails method naming conventions or good practice.
Consider the following methods:
# some methods performing some sort of 'action'
def action; end
def action!; end
# some methods checking if performing 'action' is permitted
def action?; end
def can_action?; end
def action_allowed?; end
So I wonder, which of the three ampersand-methods would be the "best" way to ask for permissions. I would go with the first one somehow, but in some cases I think this might be confused with meaning has_performed_action?.
So the second approach might make that clearer but is also a bit more verbose. The third one is actually just for completeness. I don't really like that one.
So are there any commonly agreed-on good practices for that?