Class: RackConsole

Inherits:
Object
  • Object
show all
Defined in:
lib/rack_web_console.rb,
lib/rack_console/version.rb,
lib/rack_console/output_capture.rb,
lib/rack_console/cookie_script_storage.rb

Defined Under Namespace

Classes: CookieScriptStorage, OutputCapture

Constant Summary collapse

VIEW_TEMPLATE =
::File.join __dir__, 'rack-console-view.erb'
VERSION =
'0.1.0'

Instance Method Summary collapse

Constructor Details

#initialize(_binding = binding, storage: ->(env){ CookieScriptStorage.new env }) ⇒ RackConsole

Returns a new instance of RackConsole.



10
11
12
# File 'lib/rack_web_console.rb', line 10

def initialize(_binding = binding, storage: ->(env){ CookieScriptStorage.new env })
  @storage, @binding = storage, _binding
end

Instance Method Details

#call(env) ⇒ Object



14
15
16
17
# File 'lib/rack_web_console.rb', line 14

def call(env)
  @_storage = ::Proc === @storage ? @storage[env] : @storage
  env['REQUEST_METHOD'] == 'POST' ? process_script(env) : render_view(env)
end