Created
November 8, 2009 05:31
-
-
Save hone/229116 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
| module Heroku | |
| class RackEnvironment | |
| def create_binding | |
| # handle any loading errors | |
| begin | |
| load 'config.ru' | |
| rescue | |
| $std.err.puts $! | |
| end | |
| Proc.new {}.binding | |
| end | |
| end | |
| class RailsEnvironment | |
| def create_binding | |
| # handle any loading errors | |
| begin | |
| require 'config/boot' | |
| require 'config/environment' | |
| rescue | |
| $std.err.puts $! | |
| end | |
| Proc.new {}.binding | |
| end | |
| end | |
| end | |
| if __FILE__ == $0 | |
| puts self.class.constants.size # => 90 | |
| binding = Heroku::RailsEnvironment.new.create_binding | |
| puts self.class.constants.size # => 300 | |
| eval("puts self.class.constants.size", binding) # => 0 | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment