Class: Rack::Router

Inherits:
Object show all
Defined in:
lib/cloudkit/rack/router.rb

Overview

A minimal router providing just what is needed for the OAuth and OpenID filters.

Instance Method Summary collapse

Constructor Details

#initialize(method, path, params = []) ⇒ Router

Create an instance of Router to match on method, path and params.



8
9
10
# File 'lib/cloudkit/rack/router.rb', line 8

def initialize(method, path, params=[])
  @method = method.to_s.upcase; @path = path; @params = params
end

Instance Method Details

#===(request) ⇒ Object

By overriding the case comparison operator, we can match routes in a case statement.

See also: CloudKit::Util#r, CloudKit::Request#match?



16
17
18
# File 'lib/cloudkit/rack/router.rb', line 16

def ===(request)
  request.match?(@method, @path, @params)
end