Module: Roda::RodaPlugins::Base::InstanceMethods

Defined in:
lib/roda.rb

Overview

Instance methods for the Roda class.

Instance Method Summary collapse

Instance Method Details

#call(env, &block) ⇒ Object

Create a request and response of the appopriate class, the instance_exec the route block with the request, handling any halts. This is not usually called directly.



324
325
326
327
328
# File 'lib/roda.rb', line 324

def call(env, &block)
  @_request = self.class::RodaRequest.new(self, env)
  @_response = self.class::RodaResponse.new
  _route(&block)
end

#envObject

The environment hash for the current request. Example:

env['REQUEST_METHOD'] # => 'GET'


333
334
335
# File 'lib/roda.rb', line 333

def env
  @_request.env
end

#optsObject

The class-level options hash. This should probably not be modified at the instance level. Example:

Roda.plugin :render
Roda.route do |r|
  opts[:render_opts].inspect
end


344
345
346
# File 'lib/roda.rb', line 344

def opts
  self.class.opts
end

#requestObject

The instance of the request class related to this request. This is the same object yielded by Roda.route.



350
351
352
# File 'lib/roda.rb', line 350

def request
  @_request
end

#responseObject

The instance of the response class related to this request.



355
356
357
# File 'lib/roda.rb', line 355

def response
  @_response
end

#sessionObject

The session hash for the current request. Raises RodaError if no session existsExample:

session # => {}


363
364
365
# File 'lib/roda.rb', line 363

def session
  @_request.session
end