Module: Anony::Anonymisable::ClassMethods
- Defined in:
- lib/anony/anonymisable.rb
Overview
Mixin containing methods that will be exposed on the ActiveRecord class after including the Anonymisable module.
The primary method, .anonymise, is used to configure the strategies to apply. This configuration is lazily executed when trying to actually anonymise an instance: this is because the database or other lazily-loaded properties are not necessarily available when the class is configured.
Instance Attribute Summary collapse
-
#anonymise_config ⇒ Object
readonly
Returns the value of attribute anonymise_config.
Instance Method Summary collapse
-
#anonymise { ... } ⇒ Object
Define a set of anonymisation configuration on the ActiveRecord class.
-
#valid_anonymisation? ⇒ Boolean
Check whether the model has been configured correctly.
Instance Attribute Details
#anonymise_config ⇒ Object (readonly)
Returns the value of attribute anonymise_config.
57 58 59 |
# File 'lib/anony/anonymisable.rb', line 57 def anonymise_config @anonymise_config end |
Instance Method Details
#anonymise { ... } ⇒ Object
Define a set of anonymisation configuration on the ActiveRecord class.
41 42 43 |
# File 'lib/anony/anonymisable.rb', line 41 def anonymise(&block) @anonymise_config = ModelConfig.new(self, &block) end |
#valid_anonymisation? ⇒ Boolean
Check whether the model has been configured correctly. Returns a simple ‘true`/`false`. If configuration has not yet been configured, it returns `false`.
51 52 53 54 55 |
# File 'lib/anony/anonymisable.rb', line 51 def valid_anonymisation? return false unless @anonymise_config @anonymise_config.valid? end |