Sha256: c221b81bd3732a0e6c555c13eabbc65261859c6dbdd93f3aec1ebb9064bf795e

Contents?: true

Size: 698 Bytes

Versions: 54

Compression:

Stored size: 698 Bytes

Contents

# frozen-string-literal: true

#
class Roda
  module RodaPlugins
    # The r plugin adds an +r+ instance method that will return the request.
    # This allows you to use common Roda idioms such as +r.halt+ and
    # +r.redirect+ even when +r+ isn't a local variable in scope. Example:
    # 
    #   plugin :r
    #
    #   def foo
    #     r.redirect "/bar"
    #   end
    #
    #   route do |r|
    #     r.get "foo" do
    #       foo
    #     end
    #     r.get "bar" do
    #       "bar"
    #     end
    #   end
    module R
      module InstanceMethods
        # The request object.
        def r
          @_request
        end
      end
    end

    register_plugin(:r, R)
  end
end

Version data entries

54 entries across 54 versions & 1 rubygems

Version Path
roda-3.88.0 lib/roda/plugins/r.rb
roda-3.87.0 lib/roda/plugins/r.rb
roda-3.86.0 lib/roda/plugins/r.rb
roda-3.85.0 lib/roda/plugins/r.rb
roda-3.84.0 lib/roda/plugins/r.rb
roda-3.83.0 lib/roda/plugins/r.rb
roda-3.82.0 lib/roda/plugins/r.rb
roda-3.81.0 lib/roda/plugins/r.rb
roda-3.79.0 lib/roda/plugins/r.rb
roda-3.78.0 lib/roda/plugins/r.rb
roda-3.77.0 lib/roda/plugins/r.rb
roda-3.76.0 lib/roda/plugins/r.rb
roda-3.75.0 lib/roda/plugins/r.rb
roda-3.74.0 lib/roda/plugins/r.rb
roda-3.73.0 lib/roda/plugins/r.rb
roda-3.72.0 lib/roda/plugins/r.rb
roda-3.71.0 lib/roda/plugins/r.rb
roda-3.70.0 lib/roda/plugins/r.rb
roda-3.69.0 lib/roda/plugins/r.rb
roda-3.68.0 lib/roda/plugins/r.rb