-
-
Save rstacruz/414262 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 pcall(object, meth, &blk) | |
begin | |
object.send meth | |
rescue | |
return if exception.nil? | |
raise blk.call | |
end | |
end | |
# pcall(obj, :my_method) | |
# pcall(obj, :my_method) { SomeException.new("my_method has failed") } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment