Class: Redaction::Redactor
- Inherits:
-
Object
- Object
- Redaction::Redactor
- Defined in:
- lib/redaction/redactor.rb
Instance Attribute Summary collapse
-
#models_to_redact ⇒ Object
readonly
Returns the value of attribute models_to_redact.
Instance Method Summary collapse
-
#initialize(models: nil) ⇒ Redactor
constructor
A new instance of Redactor.
- #redact! ⇒ Object
Constructor Details
#initialize(models: nil) ⇒ Redactor
Returns a new instance of Redactor.
7 8 9 |
# File 'lib/redaction/redactor.rb', line 7 def initialize(models: nil) @models_to_redact = set_models(models) end |
Instance Attribute Details
#models_to_redact ⇒ Object (readonly)
Returns the value of attribute models_to_redact.
5 6 7 |
# File 'lib/redaction/redactor.rb', line 5 def models_to_redact @models_to_redact end |
Instance Method Details
#redact! ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/redaction/redactor.rb', line 11 def redact! raise ProductionEnvironmentError if Rails.env.production? models_to_redact.each do |model| next if model.redacted_attributes.empty? model_progress = (model.name, model.count) if Redaction.config. model.all.unscoped.find_each do |record| record.redact! model_progress.increment if Redaction.config. end end end |