Class: ActiveModel::MassAssignmentSecurity::Sanitizer

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

Overview

:nodoc:

Direct Known Subclasses

LoggerSanitizer, StrictSanitizer

Instance Method Summary collapse

Instance Method Details

#sanitize(klass, attributes, authorizer) ⇒ Object

Returns all attributes not denied by the authorizer.



5
6
7
8
9
10
11
12
# File 'lib/active_model/mass_assignment_security/sanitizer.rb', line 5

def sanitize(klass, attributes, authorizer)
  rejected = []
  sanitized_attributes = attributes.reject do |key, value|
    rejected << key if authorizer.deny?(key)
  end
  process_removed_attributes(klass, rejected) unless rejected.empty?
  sanitized_attributes
end