With just that small addition:
1
2
3
4
5
6
7
8
class Symbol
alias_method :old_eeq, :"==="
def ===(obj)
(obj.respond_to?(self) && obj.send(self)) ||
old_eeq(obj)
end
end
you can do things like
1
2
3
4
5
6
case current_user
when :admin? then "admin"
when :regular? then "something_for_regulars"
when :guest? then "do_guest_stuuff"
else "huh"
end
Isn't that cool much more readable?