Class: AcceptableApi::Routes
- Inherits:
-
Object
- Object
- AcceptableApi::Routes
- Defined in:
- lib/acceptable_api/routes.rb
Instance Method Summary collapse
- #<<(route) ⇒ Object
- #for(request) ⇒ Object
-
#initialize(routes = []) ⇒ Routes
constructor
A new instance of Routes.
Constructor Details
#initialize(routes = []) ⇒ Routes
Returns a new instance of Routes.
6 7 8 |
# File 'lib/acceptable_api/routes.rb', line 6 def initialize routes = [] self.routes = routes end |
Instance Method Details
#<<(route) ⇒ Object
10 11 12 |
# File 'lib/acceptable_api/routes.rb', line 10 def << route routes << route end |
#for(request) ⇒ Object
14 15 16 17 18 |
# File 'lib/acceptable_api/routes.rb', line 14 def for request route = routes.detect { |m| m.match? request } return MissingRoute.instance unless route route end |