I think that you only half accepted this pattern and incorrectly accepted its spirit. I understand that the very purpose of the template is to avoid || .
You must have some purpose for calling current_user || redirect_out current_user || redirect_out , and this can do something with it or get some attribute. For example, suppose your code has:
(current_user || redirect_out).foo
If current_user not an instance of Null::User , you would like to call it foo . In this case, you need to define Null::User#foo as redirect_out (perhaps it will be followed by a few more operations like foo for other classes).
class Null::User def foo; redirect_out ... end end
and instead of (current_user || redirect_out).foo you should just do
current_user.foo
If current_user not an instance of Null::User , it calls foo . When this is such an instance, then the redirect_out ... procedure will be called on it.
source share