Class: DataAnon::Strategy::Field::RandomString
- Inherits:
-
Object
- Object
- DataAnon::Strategy::Field::RandomString
- Defined in:
- lib/strategy/field/string/random_string.rb
Overview
Generates random string of same length.
anonymize('UserName').using FieldStrategy::RandomString.new
Instance Method Summary collapse
Instance Method Details
#anonymize(field) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/strategy/field/string/random_string.rb', line 12 def anonymize field original_string = field.value string_words = original_string.split(' ') anonymized_string = "" string_words.each do |word| anonymized_string = anonymized_string + DataAnon::Utils::RandomString.generate(word.length) + " " end anonymized_string.strip end |