aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2008-11-14 12:27:08 +0100
committerDavid Heinemeier Hansson <david@loudthinking.com>2008-11-14 12:27:08 +0100
commitc562dfc2a7981351e2f9302c76456fae32da91b2 (patch)
tree27f90b5b0c0dbae697bcf9f74763f662f4e79a9f /actionpack/lib
parent61e43700b85de753b6254893d5365e04d3465b9a (diff)
parent2ecec6052f7f290252a9fd9cc27ec804c7aad36c (diff)
downloadrails-c562dfc2a7981351e2f9302c76456fae32da91b2.tar.gz
rails-c562dfc2a7981351e2f9302c76456fae32da91b2.tar.bz2
rails-c562dfc2a7981351e2f9302c76456fae32da91b2.zip
Merge branch 'master' of git@github.com:rails/rails
Diffstat (limited to 'actionpack/lib')
-rw-r--r--actionpack/lib/action_controller/resources.rb33
1 files changed, 14 insertions, 19 deletions
diff --git a/actionpack/lib/action_controller/resources.rb b/actionpack/lib/action_controller/resources.rb
index d6cc4aa418..7700b9d4d0 100644
--- a/actionpack/lib/action_controller/resources.rb
+++ b/actionpack/lib/action_controller/resources.rb
@@ -42,7 +42,7 @@ module ActionController
#
# Read more about REST at http://en.wikipedia.org/wiki/Representational_State_Transfer
module Resources
- INHERITABLE_OPTIONS = :namespace, :shallow, :only, :except
+ INHERITABLE_OPTIONS = :namespace, :shallow, :actions
class Resource #:nodoc:
DEFAULT_ACTIONS = :index, :create, :new, :edit, :show, :update, :destroy
@@ -119,7 +119,7 @@ module ActionController
end
def has_action?(action)
- !DEFAULT_ACTIONS.include?(action) || action_allowed?(action)
+ !DEFAULT_ACTIONS.include?(action) || @options[:actions].nil? || @options[:actions].include?(action)
end
protected
@@ -135,29 +135,24 @@ module ActionController
end
def set_allowed_actions
- only, except = @options.values_at(:only, :except)
- @allowed_actions ||= {}
+ only = @options.delete(:only)
+ except = @options.delete(:except)
- if only == :all || except == :none
- only = nil
- except = []
+ if only && except
+ raise ArgumentError, 'Please supply either :only or :except, not both.'
+ elsif only == :all || except == :none
+ options[:actions] = DEFAULT_ACTIONS
elsif only == :none || except == :all
- only = []
- except = nil
- end
-
- if only
- @allowed_actions[:only] = Array(only).map(&:to_sym)
+ options[:actions] = []
+ elsif only
+ options[:actions] = DEFAULT_ACTIONS & Array(only).map(&:to_sym)
elsif except
- @allowed_actions[:except] = Array(except).map(&:to_sym)
+ options[:actions] = DEFAULT_ACTIONS - Array(except).map(&:to_sym)
+ else
+ # leave options[:actions] alone
end
end
- def action_allowed?(action)
- only, except = @allowed_actions.values_at(:only, :except)
- (!only || only.include?(action)) && (!except || !except.include?(action))
- end
-
def set_prefixes
@path_prefix = options.delete(:path_prefix)
@name_prefix = options.delete(:name_prefix)