-
-
Save bf4/4370014 to your computer and use it in GitHub Desktop.
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
# method to evaluate the block for a default value if the | |
# conversion to date fails | |
# string.to_date return nil if the string is blank | |
# so we yield to get the default value from the block there | |
# or on a parse error | |
def string_to_date(string,&block) | |
string.to_date || yield | |
rescue => e | |
block_given? ? yield : raise | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment