Class: Anony::Strategies::OverwriteHex
- Inherits:
-
Struct
- Object
- Struct
- Anony::Strategies::OverwriteHex
- Defined in:
- lib/anony/field_level_strategies.rb
Overview
This class curries the max_length into itself so it exists as a parameterless block that can be called by Anony.
Instance Attribute Summary collapse
-
#max_length ⇒ Object
Returns the value of attribute max_length.
Instance Method Summary collapse
Instance Attribute Details
#max_length ⇒ Object
Returns the value of attribute max_length
148 149 150 |
# File 'lib/anony/field_level_strategies.rb', line 148 def max_length @max_length end |
Instance Method Details
#call(_existing_value) ⇒ Object
149 150 151 152 |
# File 'lib/anony/field_level_strategies.rb', line 149 def call(_existing_value) hex_length = (max_length / 2) + 1 SecureRandom.hex(hex_length)[0, max_length] end |