Created
June 8, 2013 21:31
-
-
Save bluekeys/5736685 to your computer and use it in GitHub Desktop.
Trying to access local variables of a block
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 Scraper | |
def scrape!(&block) | |
instance_eval &block | |
b = block.binding | |
eval("p local_variables", b) | |
end | |
end | |
s = Scraper.new | |
s.scrape! do | |
variable = "some_value" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This doesn't work, but it indicates what I would like to see.