Instance methods for the Roda class.
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, line 247 def initialize(env) klass = self.class @_request = klass::RodaRequest.new(self, env) @_response = klass::RodaResponse.new 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, line 257 def call(&block) catch(:halt) do r = @_request r.block_result(instance_exec(r, &block)) @_response.finish end end
The environment hash for the current request. Example:
env['REQUEST_METHOD'] # => 'GET'
# File lib/roda.rb, line 268 def env @_request.env 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, line 279 def opts self.class.opts end