Sha256: c9d9d5a80269b1fdb724128a99c58fe200fd5cc58f552458533e67ce1b0c8506

Contents?: true

Size: 730 Bytes

Versions: 1

Compression:

Stored size: 730 Bytes

Contents

class Roda
  module RodaPlugins
    # The pass plugin adds a request +pass+ method to skip the current +on+
    # block as if it did not match.
    #
    #   plugin :pass
    #
    #   route do |r|
    #     r.on "foo/:bar" do |bar|
    #       pass if bar == 'baz'
    #       "/foo/#{bar} (not baz)"
    #     end
    #
    #     r.on "foo/baz" do
    #       "/foo/baz"
    #     end
    #   end
    module Pass
      module RequestMethods
        # Handle passing inside the current block.
        def _on(_)
          catch(:pass){super}
        end

        # Skip the current #on block as if it did not match.
        def pass
          throw :pass
        end
      end
    end

    register_plugin(:pass, Pass)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
roda-cj-0.9.3 lib/roda/plugins/pass.rb