module Roda::RodaPlugins::RequestAref

  1. lib/roda/plugins/request_aref.rb

The request_aref plugin allows for custom handling of the r[] and r[]= methods (where r is the Request instance). In the current version of rack, these methods are deprecated, but the deprecation message is only printed in verbose mode. This plugin can allow for handling calls to these methods in one of three ways:

:allow

Allow the method calls without a deprecation, which is the historical behavior

:warn

Always issue a deprecation message by calling warn, not just in verbose mode.

:raise

Raise an error if either method is called

Methods

Public Class

  1. configure

Public Class methods

configure(app, setting)

Make [] and []= methods work as configured by aliasing the appropriate request_a(ref|set)_* methods to them.

[show source]
   # File lib/roda/plugins/request_aref.rb
20 def self.configure(app, setting)
21   case setting
22   when :allow, :raise, :warn
23     app::RodaRequest.class_eval do
24       alias_method(:[],  :"request_aref_#{setting}")
25       alias_method(:[]=, :"request_aset_#{setting}")
26       public :[], :[]=
27     end
28   else
29     raise RodaError, "Unsupport request_aref plugin setting: #{setting.inspect}"
30   end
31 end