Class: ActionDispatch::Routing::Mapper::Constraints
- Defined in:
- actionpack/lib/action_dispatch/routing/mapper.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
-
#constraints ⇒ Object
readonly
Returns the value of attribute constraints.
Class Method Summary collapse
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, constraints, request) ⇒ Constraints
constructor
A new instance of Constraints.
- #matches?(env) ⇒ Boolean
Constructor Details
#initialize(app, constraints, request) ⇒ Constraints
Returns a new instance of Constraints.
21 22 23 |
# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 21 def initialize(app, constraints, request) @app, @constraints, @request = app, constraints, request end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app
19 20 21 |
# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 19 def app @app end |
#constraints ⇒ Object (readonly)
Returns the value of attribute constraints
19 20 21 |
# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 19 def constraints @constraints end |
Class Method Details
Instance Method Details
#call(env) ⇒ Object
41 42 43 |
# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 41 def call(env) matches?(env) ? @app.call(env) : [ 404, {'X-Cascade' => 'pass'}, [] ] end |
#matches?(env) ⇒ Boolean
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 25 def matches?(env) req = @request.new(env) @constraints.each { |constraint| if constraint.respond_to?(:matches?) && !constraint.matches?(req) return false elsif constraint.respond_to?(:call) && !constraint.call(*constraint_args(constraint, req)) return false end } return true ensure req.reset_parameters end |