Permalink
Browse files

define permitted? method instead of use an alias to fix rdoc

  • Loading branch information...
1 parent 93ef857 commit f8478a78801a9c5b3116331c978130eeeaf91f00 Francesco Rodriguez committed Sep 20, 2012
Showing with 12 additions and 2 deletions.
  1. +12 −2 actionpack/lib/action_controller/metal/strong_parameters.rb
@@ -40,7 +40,8 @@ def initialize(param) # :nodoc:
# 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 @@ def initialize(param) # :nodoc:
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 @@ def initialize(attributes = nil)
@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+.
#

0 comments on commit f8478a7

Please sign in to comment.