Created
May 12, 2011 02:27
-
-
Save brentkirby/967822 to your computer and use it in GitHub Desktop.
Random examples
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
class Bob | |
def self.blocky | |
yield | |
end | |
end | |
module Death | |
def call_blocky | |
Bob.blocky do | |
puts self | |
end | |
end | |
end | |
class Another | |
include Death | |
end | |
# Another.new.call_blocky #=> #<Another:0x000001009c10e8> |
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
class Runnee | |
def self.called | |
puts self | |
end | |
end | |
class Middle | |
def self.caller(&block) | |
runner = Runnee.new | |
runner.instance_exec &block | |
end | |
end | |
class Runner < Middle | |
def self.doit | |
caller do | |
called | |
end | |
end | |
end | |
# Runner.doit #=> #<Runnee:0x000001009c73a8> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment