Class: ActionController::Routing::Optimisation::PositionalArgumentsWithAdditionalParams
- Inherits:
-
PositionalArguments
- Object
- Optimiser
- PositionalArguments
- ActionController::Routing::Optimisation::PositionalArgumentsWithAdditionalParams
- Defined in:
- lib/action_controller/routing/optimisations.rb
Overview
This case is mostly the same as the positional arguments case above, but it supports additional query parameters as the last argument
Instance Attribute Summary
Attributes inherited from Optimiser
Instance Method Summary collapse
-
#applicable? ⇒ Boolean
To avoid generating “localhost/?host=foo.example.com” we can’t use this optimisation on routes without any segments.
-
#generation_code ⇒ Object
This case uses almost the same code as positional arguments, but add an args.last.to_query on the end.
- #guard_condition ⇒ Object
Methods inherited from Optimiser
Constructor Details
This class inherits a constructor from ActionController::Routing::Optimisation::Optimiser
Instance Method Details
#applicable? ⇒ Boolean
To avoid generating “localhost/?host=foo.example.com” we can’t use this optimisation on routes without any segments
112 113 114 |
# File 'lib/action_controller/routing/optimisations.rb', line 112 def applicable? super && route.segment_keys.size > 0 end |
#generation_code ⇒ Object
This case uses almost the same code as positional arguments, but add an args.last.to_query on the end
106 107 108 |
# File 'lib/action_controller/routing/optimisations.rb', line 106 def generation_code super.insert(-2, '?#{args.last.to_query}') end |
#guard_condition ⇒ Object
100 101 102 |
# File 'lib/action_controller/routing/optimisations.rb', line 100 def guard_condition "(!defined?(default_url_options) || default_url_options.blank?) && defined?(request) && request && args.size == #{route.segment_keys.size + 1} && !args.last.has_key?(:anchor) && !args.last.has_key?(:port) && !args.last.has_key?(:host)" end |