aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/metal/strong_parameters.rb
diff options
context:
space:
mode:
authorFrancesco Rodriguez <lrodriguezsanc@gmail.com>2012-09-19 21:13:43 -0500
committerFrancesco Rodriguez <lrodriguezsanc@gmail.com>2012-09-19 22:43:29 -0500
commitf8478a78801a9c5b3116331c978130eeeaf91f00 (patch)
treec044d9cc1edad24d6fc4ec4a4d5ebbf41b658e62 /actionpack/lib/action_controller/metal/strong_parameters.rb
parent93ef857fbc93eb7f5970315624f06b84d65564c4 (diff)
downloadrails-f8478a78801a9c5b3116331c978130eeeaf91f00.tar.gz
rails-f8478a78801a9c5b3116331c978130eeeaf91f00.tar.bz2
rails-f8478a78801a9c5b3116331c978130eeeaf91f00.zip
define permitted? method instead of use an alias to fix rdoc
Diffstat (limited to 'actionpack/lib/action_controller/metal/strong_parameters.rb')
-rw-r--r--actionpack/lib/action_controller/metal/strong_parameters.rb14
1 files changed, 12 insertions, 2 deletions
diff --git a/actionpack/lib/action_controller/metal/strong_parameters.rb b/actionpack/lib/action_controller/metal/strong_parameters.rb
index 3379bcfc98..92a61c4502 100644
--- a/actionpack/lib/action_controller/metal/strong_parameters.rb
+++ b/actionpack/lib/action_controller/metal/strong_parameters.rb
@@ -40,7 +40,8 @@ module ActionController
# permitted.class # => ActionController::Parameters
# permitted.permitted? # => true
#
- # Person.first.update_attributes!(permitted) # => #<Person id: 1, name: "Francesco", age: 22, role: "user">
+ # Person.first.update_attributes!(permitted)
+ # # => #<Person id: 1, name: "Francesco", age: 22, role: "user">
#
# It provides a <tt>permit_all_parameters</tt> option that
# controls the top-level behaviour of new instances. If it's +true+,
@@ -65,7 +66,6 @@ module ActionController
class Parameters < ActiveSupport::HashWithIndifferentAccess
cattr_accessor :permit_all_parameters, instance_accessor: false
attr_accessor :permitted # :nodoc:
- alias :permitted? :permitted
# Returns a new instance of <tt>ActionController::Parameters</tt>.
# Also, sets the +permitted+ attribute to the default value of
@@ -89,6 +89,16 @@ module ActionController
@permitted = self.class.permit_all_parameters
end
+ # Returns +true+ if the parameter is permitted, +false+ otherwise.
+ #
+ # params = ActionController::Parameters.new
+ # params.permitted? # => false
+ # params.permit!
+ # params.permitted? # => true
+ def permitted?
+ @permitted
+ end
+
# Sets the +permitted+ attribute to +true+. This can be used to pass
# mass assignment. Returns +self+.
#