Instance methods for the
In addition to the listed methods, the following two methods are available:
The instance of the request class related to this request. This is the same object yielded by Roda.route.
The instance of the response class related to this request.
Public Class methods
Create a request and response of the appropriate class
# File lib/roda.rb 325 def initialize(env) 326 klass = self.class 327 @_request = klass::RodaRequest.new(self, env) 328 @_response = klass::RodaResponse.new 329 end
Public Instance methods
instance_exec the route block in the scope of the receiver, with the related request. Catch :halt so that the route block can throw :halt at any point with the rack response to use.
# File lib/roda.rb 335 def call(&block) 336 catch(:halt) do 337 r = @_request 338 r.block_result(instance_exec(r, &block)) 339 @_response.finish 340 end 341 end
The environment hash for the current request. Example:
env['REQUEST_METHOD'] # => 'GET'
# File lib/roda.rb 350 def env 351 @_request.env 352 end
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
# File lib/roda.rb 361 def opts 362 self.class.opts 363 end