Class: ActiveModel::MassAssignmentSecurity::Sanitizer

Inherits:
Object
  • Object
show all
Defined in:
activemodel/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 'activemodel/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 'activemodel/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