Class: ActionDispatch::Routing::Mapper::Constraints
Do not use. This class is for internal use only.
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
|
|
Instance Chain:
|
|
Inherits: |
ActionDispatch::Routing::Endpoint
|
Defined in: | actionpack/lib/action_dispatch/routing/mapper.rb |
Constant Summary
-
CALL =
# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 33->(app, req) { app.call req.env }
-
SERVE =
# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 32->(app, req) { app.serve req }
Class Method Summary
- .new(app, constraints, strategy) ⇒ Constraints constructor
Instance Attribute Summary
- #app readonly
- #constraints readonly
- #dispatcher? ⇒ Boolean readonly
::ActionDispatch::Routing::Endpoint
- Inherited
Instance Method Summary
::ActionDispatch::Routing::Endpoint
- Inherited
Constructor Details
.new(app, constraints, strategy) ⇒ Constraints
# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 35
def initialize(app, constraints, strategy) # Unwrap Constraints objects. I don't actually think it's possible to pass a # Constraints object to this constructor, but there were multiple places that # kept testing children of this object. I **think** they were just being # defensive, but I have no idea. if app.is_a?(self.class) constraints += app.constraints app = app.app end @strategy = strategy @app, @constraints, = app, constraints end
Instance Attribute Details
#app (readonly)
[ GitHub ]# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 30
attr_reader :app, :constraints
#constraints (readonly)
[ GitHub ]# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 30
attr_reader :app, :constraints
#dispatcher? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 50
def dispatcher?; @strategy == SERVE; end
Instance Method Details
#constraint_args(constraint, request) (private)
[ GitHub ]# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 66
def constraint_args(constraint, request) arity = if constraint.respond_to?(:arity) constraint.arity else constraint.method(:call).arity end if arity < 1 [] elsif arity == 1 [request] else [request.path_parameters, request] end end
#matches?(req) ⇒ Boolean
# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 52
def matches?(req) @constraints.all? do |constraint| (constraint.respond_to?(:matches?) && constraint.matches?(req)) || (constraint.respond_to?(:call) && constraint.call(*constraint_args(constraint, req))) end end