Module: ActiveModel::MassAssignmentSecurity
- Defined in:
- lib/whiny-mass-assignment/mass_assignment_security_overrides.rb
Defined Under Namespace
Classes: BlackList, WhiteList
Instance Method Summary
collapse
Instance Method Details
#sanitize_for_mass_assignment_with_warning(attributes) ⇒ Object
7
8
9
10
|
# File 'lib/whiny-mass-assignment/mass_assignment_security_overrides.rb', line 7
def sanitize_for_mass_assignment_with_warning(attributes)
warn_when_mass_assignment_is_not_whitelist unless mass_assignment_authorizer.is_a? WhiteList
sanitize_for_mass_assignment_without_warning(attributes)
end
|
#warn_when_mass_assignment_is_not_whitelist ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/whiny-mass-assignment/mass_assignment_security_overrides.rb', line 14
def warn_when_mass_assignment_is_not_whitelist
return if WhinyMassAssignment::Config.whitelist[:mode] == :none
only = WhinyMassAssignment::Config.whitelist[:only]
if only
return unless [only].flatten().include?( self.class )
else
except = WhinyMassAssignment::Config.whitelist[:except]
return if except && [except].flatten().include?( self.class )
end
self.logger.debug WhinyMassAssignment::bc :yellow, "Mass assignment whitelisting has not been specified for #{ WhinyMassAssignment::c [:bright, :red], self.class.name }" if self.logger
raise "Mass assignment whitelisting has not been specified for `#{self.class.name}` it is `#{mass_assignment_authorizer}`." if WhinyMassAssignment::Config.whitelist[:mode] == :raise
end
|