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 512 def initialize(env) 513 klass = self.class 514 @_request = klass::RodaRequest.new(self, env) 515 @_response = klass::RodaResponse.new 516 end
Public Instance methods
Handle dispatching to the main route, catching :halt and handling the result of the block.
# File lib/roda.rb 520 def _roda_handle_main_route 521 catch(:halt) do 522 r = @_request 523 r.block_result(_roda_run_main_route(r)) 524 @_response.finish 525 end 526 end
Treat the given block as a routing block, catching :halt if thrown by the block.
# File lib/roda.rb 530 def _roda_handle_route 531 catch(:halt) do 532 @_request.block_result(yield) 533 @_response.finish 534 end 535 end
Default implementation of the main route, usually overridden by Roda.route.
# File lib/roda.rb 539 def _roda_main_route(_) 540 end
Run the main route block with the request. Designed for extension by plugins
# File lib/roda.rb 544 def _roda_run_main_route(r) 545 _roda_main_route(r) 546 end
Deprecated method for the previous main route dispatch API.
# File lib/roda.rb 549 def call(&block) 550 # RODA4: Remove 551 catch(:halt) do 552 r = @_request 553 r.block_result(instance_exec(r, &block)) # Fallback 554 @_response.finish 555 end 556 end
The environment hash for the current request. Example:
env['REQUEST_METHOD'] # => 'GET'
# File lib/roda.rb 566 def env 567 @_request.env 568 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 577 def opts 578 self.class.opts 579 end
The session hash for the current request. Raises RodaError if no session exists. Example:
session # => {}
# File lib/roda.rb 593 def session 594 @_request.session 595 end