Class: RubyEventStore::Browser::Router::Route
- Inherits:
-
Object
- Object
- RubyEventStore::Browser::Router::Route
- Defined in:
- lib/ruby_event_store/browser/router.rb
Instance Method Summary collapse
- #call(params, urls) ⇒ Object
-
#initialize(request_method, pattern, &block) ⇒ Route
constructor
A new instance of Route.
- #match(request) ⇒ Object
Constructor Details
#initialize(request_method, pattern, &block) ⇒ Route
Returns a new instance of Route.
12 13 14 15 16 |
# File 'lib/ruby_event_store/browser/router.rb', line 12 def initialize(request_method, pattern, &block) @request_method = request_method @pattern = pattern @handler = block end |
Instance Method Details
#call(params, urls) ⇒ Object
25 26 27 |
# File 'lib/ruby_event_store/browser/router.rb', line 25 def call(params, urls) handler[params, urls] end |
#match(request) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/ruby_event_store/browser/router.rb', line 18 def match(request) return unless request.request_method.eql?(request_method) match_data = regexp.match(File.join("/", request.path_info)) match_data.named_captures.transform_values { |v| Rack::Utils.unescape(v) } if match_data end |