rails/rails — pull request #12669 by ulyssecarion (2013-10-28 01:17:45+00:00)
Title: Define `alias_antonym` to quickly create "opposite" methods.

Defining "antonym" (aka "opposite" or "inverse") methods that return precisely the opposite of what another method returns is a pretty common idiom in both Rails and other applications, so I thought it might be a decent idea to encapsulate this pattern in a method `alias_antonym`.

An example in action:

```ruby
class ParityChecker
class << self
def even?(n)
n % 2 == 0
end

alias_antonym :odd?, :even?
end
end

ParityChecker.even?(5) # => false
ParityChecker.odd?(5) # => true
```

Unlike `alias_method`, `alias_antonym` doesn't make a copy of a method because that wouldn't make any sense. Instead, it just defines `new_method` as `not old_method`. I suppose this makes the "alias" part of the name kinda misleading, but I couldn't think of a better name at the time.

This is my first time submitting to a real PR to Rails, so I apologize if I missed any steps in the process.