Skip to content

Instantly share code, notes, and snippets.

@hone
Created November 8, 2009 05:31
Show Gist options
  • Select an option

  • Save hone/229116 to your computer and use it in GitHub Desktop.

Select an option

Save hone/229116 to your computer and use it in GitHub Desktop.
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