Class: Rack::Webconsole::Sandbox
- Inherits:
-
Object
- Object
- Rack::Webconsole::Sandbox
- Defined in:
- lib/rack/webconsole/sandbox.rb
Overview
A sandbox to evaluate Ruby in. It is responsible for retrieving local variables stored in `@locals`, and resetting the environment.
Instance Method Summary (collapse)
-
- (Object) method_missing(method, *args, &block)
Catches all the undefined local variables and tries to retrieve them from `@locals`.
-
- (String) reload!
Makes the console use a fresh, new Sandbox with all local variables resetted.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
- (Object) method_missing(method, *args, &block)
Catches all the undefined local variables and tries to retrieve them from `@locals`. If it doesn't find them, it falls back to the default method missing behavior.
11 12 13 14 |
# File 'lib/rack/webconsole/sandbox.rb', line 11 def method_missing(method, *args, &block) @locals ||= {} @locals[method] || super(method, *args, &block) end |
Instance Method Details
- (String) reload!
Makes the console use a fresh, new Rack::Webconsole::Sandbox with all local variables resetted.
20 21 22 23 |
# File 'lib/rack/webconsole/sandbox.rb', line 20 def reload! $sandbox = Sandbox.new 'ok' end |