Skip to content

Instantly share code, notes, and snippets.

@mattsnyder
Created July 8, 2011 13:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattsnyder/1071802 to your computer and use it in GitHub Desktop.
Save mattsnyder/1071802 to your computer and use it in GitHub Desktop.
Offer up a replacement should the prefered value not be present
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