Class: DummyOscar::Router
- Inherits:
-
Object
- Object
- DummyOscar::Router
- Defined in:
- lib/dummy_oscar/router.rb
Defined Under Namespace
Classes: Route
Instance Method Summary collapse
- #add(path:, method:, response:) ⇒ Object
- #find(path:, method:) ⇒ Object
-
#initialize ⇒ Router
constructor
A new instance of Router.
Constructor Details
#initialize ⇒ Router
Returns a new instance of Router.
6 7 8 |
# File 'lib/dummy_oscar/router.rb', line 6 def initialize @routes = [] end |
Instance Method Details
#add(path:, method:, response:) ⇒ Object
10 11 12 |
# File 'lib/dummy_oscar/router.rb', line 10 def add(path:, method:, response:) @routes << Route.new(path, method.downcase, response) end |
#find(path:, method:) ⇒ Object
14 15 16 17 18 |
# File 'lib/dummy_oscar/router.rb', line 14 def find(path:, method:) @routes.detect do |route| /\A(?:#{route.path})\z/.match?(path) && route.method == method.downcase end end |