Class: RouteMatcher
- Inherits:
-
Object
- Object
- RouteMatcher
- Defined in:
- lib/route_matcher.rb
Constant Summary collapse
- PATH_PARAMETERS =
"_DISCOURSE_REQUEST_PATH_PARAMETERS"
Instance Attribute Summary collapse
-
#actions ⇒ Object
readonly
Returns the value of attribute actions.
-
#aliases ⇒ Object
readonly
Returns the value of attribute aliases.
-
#allowed_param_values ⇒ Object
readonly
Returns the value of attribute allowed_param_values.
-
#formats ⇒ Object
readonly
Returns the value of attribute formats.
-
#methods ⇒ Object
readonly
Returns the value of attribute methods.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
Instance Method Summary collapse
-
#initialize(actions: nil, params: nil, methods: nil, formats: nil, aliases: nil, allowed_param_values: nil) ⇒ RouteMatcher
constructor
A new instance of RouteMatcher.
- #match?(env:) ⇒ Boolean
-
#with_allowed_param_values(new_allowed_param_values) ⇒ Object
Return an identical route matcher, with the allowed_param_values replaced.
Constructor Details
#initialize(actions: nil, params: nil, methods: nil, formats: nil, aliases: nil, allowed_param_values: nil) ⇒ RouteMatcher
Returns a new instance of RouteMatcher.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/route_matcher.rb', line 8 def initialize( actions: nil, params: nil, methods: nil, formats: nil, aliases: nil, allowed_param_values: nil ) @actions = Array(actions) if actions @params = Array(params) if params @methods = Array(methods) if methods @formats = Array(formats) if formats @aliases = aliases @allowed_param_values = allowed_param_values end |
Instance Attribute Details
#actions ⇒ Object (readonly)
Returns the value of attribute actions.
6 7 8 |
# File 'lib/route_matcher.rb', line 6 def actions @actions end |
#aliases ⇒ Object (readonly)
Returns the value of attribute aliases.
6 7 8 |
# File 'lib/route_matcher.rb', line 6 def aliases @aliases end |
#allowed_param_values ⇒ Object (readonly)
Returns the value of attribute allowed_param_values.
6 7 8 |
# File 'lib/route_matcher.rb', line 6 def allowed_param_values @allowed_param_values end |
#formats ⇒ Object (readonly)
Returns the value of attribute formats.
6 7 8 |
# File 'lib/route_matcher.rb', line 6 def formats @formats end |
#methods ⇒ Object (readonly)
Returns the value of attribute methods.
6 7 8 |
# File 'lib/route_matcher.rb', line 6 def methods @methods end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
6 7 8 |
# File 'lib/route_matcher.rb', line 6 def params @params end |
Instance Method Details
#match?(env:) ⇒ Boolean
36 37 38 39 40 41 |
# File 'lib/route_matcher.rb', line 36 def match?(env:) request = ActionDispatch::Request.new(env) action_allowed?(request) && params_allowed?(request) && method_allowed?(request) && format_allowed?(request) end |
#with_allowed_param_values(new_allowed_param_values) ⇒ Object
Return an identical route matcher, with the allowed_param_values replaced
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/route_matcher.rb', line 25 def with_allowed_param_values(new_allowed_param_values) RouteMatcher.new( actions: actions, params: params, methods: methods, formats: formats, aliases: aliases, allowed_param_values: new_allowed_param_values, ) end |