Clearer Conditionals using De Morgan's Laws

Let’s use De Morgan’s Laws to clean it up and see who actually has access to our
site.

De Morgan’s Laws

Whoa, who’s this De Morgan guy? Augustus De Morgan, in addition to
looking like a 19th-century John C. Reilly, formulated two important
rules of logical inference. You can check out the formal definition on the
Wikipedia page, but here they are in Ruby code:

# First law
!(a && b) == !a || !b
# Second law
!(a || b) == !a && !b

Well hey, it looks like we can use these on our gnarly conditional above. Let’s try it.

Law-abiding Ruby code

Recall that the original conditional was ! (signed_out? && untrusted_ip?).
Let’s use the first law and puzzle it out.

These methods, signed_in? and trusted_ip?, might exist and they might not.
Creating them is part of this refactoring. You might even end up removing the
signed_out? and untrusted_ip? methods in favor of these new,
positively-named methods.

And that’s it. We took a hard-to-parse conditional and made it clearer and
easier-to-read using De Morgan’s first law.