Class: ActiveRecordAnonymizer::AttributesAnonymizer
- Inherits:
-
Object
- Object
- ActiveRecordAnonymizer::AttributesAnonymizer
- Defined in:
- lib/active_record_anonymizer/attributes_anonymizer.rb
Instance Attribute Summary collapse
-
#model ⇒ Object
readonly
Returns the value of attribute model.
Instance Method Summary collapse
- #anonymize_columns ⇒ Object
-
#initialize(model, skip_update: false) ⇒ AttributesAnonymizer
constructor
A new instance of AttributesAnonymizer.
- #populate ⇒ Object
Constructor Details
#initialize(model, skip_update: false) ⇒ AttributesAnonymizer
Returns a new instance of AttributesAnonymizer.
7 8 9 10 |
# File 'lib/active_record_anonymizer/attributes_anonymizer.rb', line 7 def initialize(model, skip_update: false) @model = model @skip_update = skip_update end |
Instance Attribute Details
#model ⇒ Object (readonly)
Returns the value of attribute model.
5 6 7 |
# File 'lib/active_record_anonymizer/attributes_anonymizer.rb', line 5 def model @model end |
Instance Method Details
#anonymize_columns ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/active_record_anonymizer/attributes_anonymizer.rb', line 12 def anonymize_columns if model.new_record? anonymize_all_attributes else # Skip updating the record if skip_update is true return if @skip_update anonymize_changed_columns end end |
#populate ⇒ Object
23 24 25 26 |
# File 'lib/active_record_anonymizer/attributes_anonymizer.rb', line 23 def populate anonymize_all_attributes model.save! end |