Created
December 15, 2015 16:18
-
-
Save TheKidCoder/402b7e77aae48a3da34d 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
class Thinger | |
def run! | |
[:first_thing, :second_thing, :third_thing].map do |meth_name| | |
begin | |
self.method(meth_name).call | |
rescue => e | |
puts "There was a problem running: #{meth_name}" | |
next | |
end | |
end | |
end | |
def first_thing | |
puts "I'm the first to go!" | |
end | |
def second_thing | |
raise StandardError, "Oh no!" | |
end | |
def third_thing | |
puts "Last to finish!" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
send
. If anything,public_send
is better and using this method you can do other things, (maybe a conditional on the arity of the method).