Class: ActiveModel::MassAssignmentSecurity::Sanitizer

Inherits:
Object
  • Object
show all
Defined in:
lib/active_model/mass_assignment_security/sanitizer.rb

Direct Known Subclasses

LoggerSanitizer, StrictSanitizer

Instance Method Summary collapse

Constructor Details

#initialize(target = nil) ⇒ Sanitizer

Returns a new instance of Sanitizer.



6
7
# File 'lib/active_model/mass_assignment_security/sanitizer.rb', line 6

def initialize(target=nil)
end

Instance Method Details

#sanitize(attributes, authorizer) ⇒ Object

Returns all attributes not denied by the authorizer.



10
11
12
13
14
# File 'lib/active_model/mass_assignment_security/sanitizer.rb', line 10

def sanitize(attributes, authorizer)
  sanitized_attributes = attributes.reject { |key, value| authorizer.deny?(key) }
  debug_protected_attribute_removal(attributes, sanitized_attributes)
  sanitized_attributes
end