Class: RocketShorts::RoutingConstraints
- Inherits:
-
Object
- Object
- RocketShorts::RoutingConstraints
- Defined in:
- lib/rocket_shorts/routing_constraints.rb
Instance Method Summary collapse
-
#initialize(options) ⇒ RoutingConstraints
constructor
A new instance of RoutingConstraints.
- #matches?(req) ⇒ Boolean
Constructor Details
#initialize(options) ⇒ RoutingConstraints
Returns a new instance of RoutingConstraints.
3 4 5 6 7 |
# File 'lib/rocket_shorts/routing_constraints.rb', line 3 def initialize() @version = [:version] @versions = [:versions] @default = [:default] end |
Instance Method Details
#matches?(req) ⇒ Boolean
9 10 11 12 13 14 15 |
# File 'lib/rocket_shorts/routing_constraints.rb', line 9 def matches?(req) if @versions.present? @default || req.headers['Accept'].match(/#{RocketShorts.header_format}#{@versions}/) else @default || req.headers['Accept'].match(/#{RocketShorts.header_format}#{@version}/) end end |