Class: ActionDispatch::Routing::Mapper::Constraints
- Inherits:
-
Object
- Object
- ActionDispatch::Routing::Mapper::Constraints
- Defined in:
- lib/action_dispatch/routing/mapper.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
Class Method Summary collapse
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, constraints, request) ⇒ Constraints
constructor
A new instance of Constraints.
Constructor Details
#initialize(app, constraints, request) ⇒ Constraints
Returns a new instance of Constraints.
19 20 21 |
# File 'lib/action_dispatch/routing/mapper.rb', line 19 def initialize(app, constraints, request) @app, @constraints, @request = app, constraints, request end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
17 18 19 |
# File 'lib/action_dispatch/routing/mapper.rb', line 17 def app @app end |
Class Method Details
.new(app, constraints, request = Rack::Request) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/action_dispatch/routing/mapper.rb', line 9 def self.new(app, constraints, request = Rack::Request) if constraints.any? super(app, constraints, request) else app end end |
Instance Method Details
#call(env) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/action_dispatch/routing/mapper.rb', line 23 def call(env) req = @request.new(env) @constraints.each { |constraint| if constraint.respond_to?(:matches?) && !constraint.matches?(req) return [ 404, {'X-Cascade' => 'pass'}, [] ] elsif constraint.respond_to?(:call) && !constraint.call(*constraint_args(constraint, req)) return [ 404, {'X-Cascade' => 'pass'}, [] ] end } @app.call(env) end |