Class: Cocaine::Sandbox

Inherits:
Object show all
Defined in:
lib/cocaine/server/sandbox.rb

Defined Under Namespace

Modules: Errno

Instance Method Summary collapse

Constructor Details

#initializeSandbox

Returns a new instance of Sandbox.



10
11
12
# File 'lib/cocaine/server/sandbox.rb', line 10

def initialize
  @handlers = {}
end

Instance Method Details

#invoke(event, request, response) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/cocaine/server/sandbox.rb', line 18

def invoke(event, request, response)
  if @handlers.has_key? event
    invoke_handler event, request, response
  else
    write_error Errno::NO_SUCH_EVENT, "application has no event '#{event}'", response
  end
end

#on(event, handler) ⇒ Object



14
15
16
# File 'lib/cocaine/server/sandbox.rb', line 14

def on(event, handler)
  @handlers[event] = handler
end