From 78e37f45c64838b120699317068cf1950277897c Mon Sep 17 00:00:00 2001 From: Rick Olson Date: Mon, 31 Jul 2006 21:57:59 +0000 Subject: Fix bug when passing multiple options to SimplyRestful, like :new => { :preview => :get, :draft => :get }. [Rick Olson, Josh Susser, Lars Pind] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4641 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/lib/action_controller/resources.rb | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) (limited to 'actionpack/lib/action_controller/resources.rb') diff --git a/actionpack/lib/action_controller/resources.rb b/actionpack/lib/action_controller/resources.rb index 93016cbcc5..2b4c9217d5 100644 --- a/actionpack/lib/action_controller/resources.rb +++ b/actionpack/lib/action_controller/resources.rb @@ -11,7 +11,7 @@ module ActionController @singular = options[:singular] || plural.to_s.singularize @options = options - + arrange_actions add_default_actions set_prefixes @@ -56,30 +56,17 @@ module ActionController @path_prefix = options.delete(:path_prefix) @name_prefix = options.delete(:name_prefix) end - + def arrange_actions_by_methods(actions) - arrayize_values(flip_keys_and_values(actions || {})) + (actions || {}).inject({}) do |flipped_hash, (key, value)| + (flipped_hash[value] ||= []) << key + flipped_hash + end end def add_default_action(collection, method, action) (collection[method] ||= []).unshift(action) end - - def flip_keys_and_values(hash) - hash.inject({}) do |flipped_hash, (key, value)| - flipped_hash[value] = key - flipped_hash - end - end - - def arrayize_values(hash) - hash.each do |(key, value)| - unless value.is_a?(Array) - hash[key] = [] - hash[key] << value - end - end - end end def resources(*entities) -- cgit v1.2.3