Class: ActionDispatch::Routing::RouteSet::NamedRouteCollection::UrlHelper::OptimizedUrlHelper
- Inherits:
-
ActionDispatch::Routing::RouteSet::NamedRouteCollection::UrlHelper
- Object
- ActionDispatch::Routing::RouteSet::NamedRouteCollection::UrlHelper
- ActionDispatch::Routing::RouteSet::NamedRouteCollection::UrlHelper::OptimizedUrlHelper
- Defined in:
- lib/action_dispatch/routing/route_set.rb
Instance Attribute Summary collapse
-
#arg_size ⇒ Object
readonly
Returns the value of attribute arg_size.
Attributes inherited from ActionDispatch::Routing::RouteSet::NamedRouteCollection::UrlHelper
Instance Method Summary collapse
- #call(t, method_name, args, inner_options, url_strategy) ⇒ Object
-
#initialize(route, options, route_name) ⇒ OptimizedUrlHelper
constructor
A new instance of OptimizedUrlHelper.
Methods inherited from ActionDispatch::Routing::RouteSet::NamedRouteCollection::UrlHelper
create, #handle_positional_args, optimize_helper?
Constructor Details
#initialize(route, options, route_name) ⇒ OptimizedUrlHelper
Returns a new instance of OptimizedUrlHelper.
208 209 210 211 212 |
# File 'lib/action_dispatch/routing/route_set.rb', line 208 def initialize(route, , route_name) super @required_parts = @route.required_parts @arg_size = @required_parts.size end |
Instance Attribute Details
#arg_size ⇒ Object (readonly)
Returns the value of attribute arg_size.
206 207 208 |
# File 'lib/action_dispatch/routing/route_set.rb', line 206 def arg_size @arg_size end |
Instance Method Details
#call(t, method_name, args, inner_options, url_strategy) ⇒ Object
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 |
# File 'lib/action_dispatch/routing/route_set.rb', line 214 def call(t, method_name, args, , url_strategy) if args.size == arg_size && ! && optimize_routes_generation?(t) = t..merge @options path = optimized_helper(args) path << "/" if [:trailing_slash] && !path.end_with?("/") [:path] = path original_script_name = .delete(:original_script_name) script_name = t._routes.find_script_name() if original_script_name script_name = original_script_name + script_name end [:script_name] = script_name url_strategy.call else super end end |