-
-
Save leejarvis/62513bf48b7fff7b1e2e 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
#!/usr/bin/env ruby | |
def register(object = nil, &block) | |
obj = block_given? ? block : object | |
obj.call if obj.respond_to?(:call) | |
end | |
class MyClass | |
def call | |
puts "three" | |
end | |
end | |
register proc { puts "one" } | |
register { puts "two" } | |
register MyClass.new | |
register "foo" # fail silently | |
# one | |
# two | |
# three |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment