module Anony::Anonymisable::ClassMethods
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.
Attributes
Public Instance Methods
Define a set of anonymisation configuration on the ActiveRecord class.
@yield A configuration block @see DSL Anony::Strategies::Overwrite
- the methods available inside this block @example
class Manager < ApplicationRecord anonymise do overwrite do with_strategy(:first_name) { "ANONYMISED" } end end end
# File lib/anony/anonymisable.rb, line 41 def anonymise(&block) @anonymise_config = ModelConfig.new(self, &block) end
Check whether the model has been configured correctly. Returns a simple `true`/`false`. If configuration has not yet been configured, it returns `false`.
@return [Boolean] @example
Manager.valid_anonymisation?
# File lib/anony/anonymisable.rb, line 51 def valid_anonymisation? return false unless @anonymise_config @anonymise_config.valid? end