aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2014-05-08 11:21:44 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2014-05-12 15:54:45 -0700
commitcc1ff82df47fe46b2a53af421c71f3189b8738a5 (patch)
tree8a04ce6d05b8fa3a086ed23015d7013070116f70 /actionpack
parent3095f5ba38a7c230d5732af0128d9ddd7142ff7f (diff)
downloadrails-cc1ff82df47fe46b2a53af421c71f3189b8738a5.tar.gz
rails-cc1ff82df47fe46b2a53af421c71f3189b8738a5.tar.bz2
rails-cc1ff82df47fe46b2a53af421c71f3189b8738a5.zip
push list handling to the builder object
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_dispatch/routing/polymorphic_routes.rb60
1 files changed, 30 insertions, 30 deletions
diff --git a/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb b/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb
index 9859b6907d..282e6ca506 100644
--- a/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb
+++ b/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb
@@ -125,10 +125,9 @@ module ActionDispatch
recipient = record_or_hash_or_array.shift
end
- method, args = handle_list record_or_hash_or_array,
- prefix,
- suffix,
- inflection
+ method, args = builder.handle_list record_or_hash_or_array,
+ prefix,
+ suffix
when Hash
unless record_or_hash_or_array[:id]
raise ArgumentError, "Nil location provided. Can't build URI."
@@ -227,51 +226,52 @@ module ActionDispatch
[named_route, args]
end
- end
-
- ROUTE_KEY = lambda { |name| name.route_key }
- SINGULAR_ROUTE_KEY = lambda { |name| name.singular_route_key }
- def handle_list(list, prefix, suffix, inflection)
- record_list = list.dup
- record = record_list.pop
+ def handle_list(list, prefix, suffix)
+ record_list = list.dup
+ record = record_list.pop
- args = []
+ args = []
- route = record_list.map { |parent|
- case parent
- when Symbol, String
- parent.to_s
- when Class
- args << parent
- parent.model_name.singular_route_key
- else
- args << parent.to_model
- parent.to_model.class.model_name.singular_route_key
- end
- }
+ route = record_list.map { |parent|
+ case parent
+ when Symbol, String
+ parent.to_s
+ when Class
+ args << parent
+ parent.model_name.singular_route_key
+ else
+ args << parent.to_model
+ parent.to_model.class.model_name.singular_route_key
+ end
+ }
- route <<
+ route <<
case record
when Symbol, String
record.to_s
when Class
- inflection.call record.model_name
+ @key_strategy.call record.model_name
else
if record.persisted?
args << record.to_model
record.to_model.class.model_name.singular_route_key
else
- inflection.call record.to_model.class.model_name
+ @key_strategy.call record.to_model.class.model_name
end
end
- route << suffix
+ route << suffix
- named_route = prefix + route.join("_")
- [named_route, args]
+ named_route = prefix + route.join("_")
+ [named_route, args]
+ end
end
+ ROUTE_KEY = lambda { |name| name.route_key }
+ SINGULAR_ROUTE_KEY = lambda { |name| name.singular_route_key }
+
+
def model_path_helper_call(record)
handle_model record, ''.freeze, "path".freeze, ROUTE_KEY
end