Class: Anonymizable::Configuration
- Inherits:
-
Object
- Object
- Anonymizable::Configuration
- Defined in:
- lib/anonymizable/configuration.rb
Instance Attribute Summary collapse
-
#associations_to_anonymize ⇒ Object
readonly
Returns the value of attribute associations_to_anonymize.
-
#associations_to_delete ⇒ Object
readonly
Returns the value of attribute associations_to_delete.
-
#associations_to_destroy ⇒ Object
readonly
Returns the value of attribute associations_to_destroy.
-
#attrs_to_anonymize ⇒ Object
readonly
Returns the value of attribute attrs_to_anonymize.
-
#attrs_to_nullify ⇒ Object
readonly
Returns the value of attribute attrs_to_nullify.
-
#guard ⇒ Object
readonly
Returns the value of attribute guard.
-
#post_anonymization_callbacks ⇒ Object
readonly
Returns the value of attribute post_anonymization_callbacks.
Instance Method Summary collapse
- #after(*callbacks) ⇒ Object
- #associations(*associations, &block) ⇒ Object
- #attributes(*attrs) ⇒ Object
-
#initialize(klass) ⇒ Configuration
constructor
A new instance of Configuration.
- #only_if(callback) ⇒ Object
- #public? ⇒ Boolean
- #raise_on_delete? ⇒ Boolean
Constructor Details
#initialize(klass) ⇒ Configuration
Returns a new instance of Configuration.
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/anonymizable/configuration.rb', line 16 def initialize(klass) @klass = klass @guard = nil @attrs_to_nullify = Set.new @attrs_to_anonymize = Hash.new @associations_to_anonymize = Set.new @associations_to_delete = Set.new @associations_to_destroy = Set.new @post_anonymization_callbacks = Set.new @public = false @raise_on_delete = false end |
Instance Attribute Details
#associations_to_anonymize ⇒ Object (readonly)
Returns the value of attribute associations_to_anonymize.
8 9 10 |
# File 'lib/anonymizable/configuration.rb', line 8 def associations_to_anonymize @associations_to_anonymize end |
#associations_to_delete ⇒ Object (readonly)
Returns the value of attribute associations_to_delete.
8 9 10 |
# File 'lib/anonymizable/configuration.rb', line 8 def associations_to_delete @associations_to_delete end |
#associations_to_destroy ⇒ Object (readonly)
Returns the value of attribute associations_to_destroy.
8 9 10 |
# File 'lib/anonymizable/configuration.rb', line 8 def associations_to_destroy @associations_to_destroy end |
#attrs_to_anonymize ⇒ Object (readonly)
Returns the value of attribute attrs_to_anonymize.
8 9 10 |
# File 'lib/anonymizable/configuration.rb', line 8 def attrs_to_anonymize @attrs_to_anonymize end |
#attrs_to_nullify ⇒ Object (readonly)
Returns the value of attribute attrs_to_nullify.
8 9 10 |
# File 'lib/anonymizable/configuration.rb', line 8 def attrs_to_nullify @attrs_to_nullify end |
#guard ⇒ Object (readonly)
Returns the value of attribute guard.
8 9 10 |
# File 'lib/anonymizable/configuration.rb', line 8 def guard @guard end |
#post_anonymization_callbacks ⇒ Object (readonly)
Returns the value of attribute post_anonymization_callbacks.
8 9 10 |
# File 'lib/anonymizable/configuration.rb', line 8 def post_anonymization_callbacks @post_anonymization_callbacks end |
Instance Method Details
#after(*callbacks) ⇒ Object
49 50 51 52 53 54 55 |
# File 'lib/anonymizable/configuration.rb', line 49 def after(*callbacks) callbacks.each do |callback| validate_callback(callback) end @post_anonymization_callbacks += callbacks end |
#associations(*associations, &block) ⇒ Object
45 46 47 |
# File 'lib/anonymizable/configuration.rb', line 45 def associations(*associations, &block) instance_eval(&block) end |
#attributes(*attrs) ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'lib/anonymizable/configuration.rb', line 35 def attributes(*attrs) @attrs_to_anonymize.merge! attrs. attrs.each do |attr| validate_attribute(attr) end @attrs_to_nullify += attrs end |
#only_if(callback) ⇒ Object
29 30 31 32 33 |
# File 'lib/anonymizable/configuration.rb', line 29 def only_if(callback) validate_callback(callback) @guard = callback end |
#public? ⇒ Boolean
57 58 59 |
# File 'lib/anonymizable/configuration.rb', line 57 def public? @public end |
#raise_on_delete? ⇒ Boolean
61 62 63 |
# File 'lib/anonymizable/configuration.rb', line 61 def raise_on_delete? @raise_on_delete end |