Module: Pepper::App::InstanceMethods

Defined in:
lib/pepper.rb

Overview

The interface for Rack to connect to using the call method

Defined Under Namespace

Classes: Error404, ErrorMethodNotSupported, ErrorRootContextNotFound

Instance Method Summary collapse

Instance Method Details

#call(rack_env) ⇒ Object



362
363
364
365
366
367
368
369
370
371
372
373
# File 'lib/pepper.rb', line 362

def call(rack_env)
  @response=Rack::Response.new
  @request=Request.new(rack_env)
  raise ErrorRootContextNotFound if root.nil?
  root.app=self
  context = root.resolve(request.path_info_slices)
  raise Error404 if context.nil?
  action = context.find_action(request.method_sym, request.env)
  raise ErrorMethodNotSupported if action.nil?
  response.write action.execute!
  response.finish
end

#header(name, value) ⇒ Object



354
355
356
# File 'lib/pepper.rb', line 354

def header(name, value)
  response[name]=value
end

#headers(hash) ⇒ Object



358
359
360
# File 'lib/pepper.rb', line 358

def headers(hash)
  hash.each_pair {|k,v|header(k,v)}
end

#requestObject



350
# File 'lib/pepper.rb', line 350

def request; @request end

#responseObject



352
# File 'lib/pepper.rb', line 352

def response; @response; end

#rootObject



349
# File 'lib/pepper.rb', line 349

def root; self.class.root end