Created
February 11, 2011 20:45
-
-
Save r00k/822994 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def foo? | |
self.status == 'foo' | |
end | |
def bar? | |
self.status == 'bar' | |
end | |
# duplication! accomplish the same thing with define_method: | |
[:foo, :bar].each do |status| | |
define_method("#{status}?") do | |
self.status == status.to_s | |
end | |
end | |
# awwwww yeah |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment