Created
July 8, 2011 13:16
-
-
Save mattsnyder/1071802 to your computer and use it in GitHub Desktop.
Offer up a replacement should the prefered value not be present
This file contains 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 Prefer(value) | |
if value.present? then | |
value | |
else | |
block_given? ? yield : NullObject.new | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment