Instance methods for the Roda class.
In addition to the listed methods, the following two methods are available:
| request |
The instance of the request class related to this request. This is the same object yielded by Roda.route. |
| response |
The instance of the response class related to this request. |
Methods
Public Class
Public Instance
Public Class methods
Create a request and response of the appropriate class
# File lib/roda.rb 496 def initialize(env) 497 klass = self.class 498 @_request = klass::RodaRequest.new(self, env) 499 @_response = klass::RodaResponse.new 500 end
Public Instance methods
Handle dispatching to the main route, catching :halt and handling the result of the block.
# File lib/roda.rb 504 def _roda_handle_main_route 505 catch(:halt) do 506 r = @_request 507 r.block_result(_roda_run_main_route(r)) 508 @_response.finish 509 end 510 end
Treat the given block as a routing block, catching :halt if thrown by the block.
# File lib/roda.rb 514 def _roda_handle_route 515 catch(:halt) do 516 @_request.block_result(yield) 517 @_response.finish 518 end 519 end
Default implementation of the main route, usually overridden by Roda.route.
# File lib/roda.rb 523 def _roda_main_route(_) 524 end
Run the main route block with the request. Designed for extension by plugins
# File lib/roda.rb 528 def _roda_run_main_route(r) 529 _roda_main_route(r) 530 end
Deprecated method for the previous main route dispatch API.
# File lib/roda.rb 533 def call(&block) 534 # RODA4: Remove 535 catch(:halt) do 536 r = @_request 537 r.block_result(instance_exec(r, &block)) # Fallback 538 @_response.finish 539 end 540 end
The environment hash for the current request. Example:
env['REQUEST_METHOD'] # => 'GET'
# File lib/roda.rb 550 def env 551 @_request.env 552 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 561 def opts 562 self.class.opts 563 end
The session hash for the current request. Raises RodaError if no session exists. Example:
session # => {}
# File lib/roda.rb 577 def session 578 @_request.session 579 end