From fd2d78dbc89a5875fb6e70416b991b371ea33468 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Wed, 4 Jan 2012 13:15:48 -0800 Subject: push target down to the classes that care about it --- .../lib/active_model/mass_assignment_security/sanitizer.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/activemodel/lib/active_model/mass_assignment_security/sanitizer.rb b/activemodel/lib/active_model/mass_assignment_security/sanitizer.rb index caf2a25573..33259b98bd 100644 --- a/activemodel/lib/active_model/mass_assignment_security/sanitizer.rb +++ b/activemodel/lib/active_model/mass_assignment_security/sanitizer.rb @@ -1,9 +1,6 @@ module ActiveModel module MassAssignmentSecurity class Sanitizer - def initialize(target=nil) - end - # Returns all attributes not denied by the authorizer. def sanitize(attributes, authorizer) sanitized_attributes = attributes.reject { |key, value| authorizer.deny?(key) } @@ -26,7 +23,7 @@ module ActiveModel class LoggerSanitizer < Sanitizer def initialize(target) @target = target - super + super() end def logger @@ -43,6 +40,10 @@ module ActiveModel end class StrictSanitizer < Sanitizer + def initialize(target = nil) + super() + end + def process_removed_attributes(attrs) return if (attrs - insensitive_attributes).empty? raise ActiveModel::MassAssignmentSecurity::Error, "Can't mass-assign protected attributes: #{attrs.join(', ')}" -- cgit v1.2.3