Class: GdprAdmin::ApplicationDataPolicy

Inherits:
Object
  • Object
show all
Includes:
Helpers::DataPolicyHelper, Helpers::EraseHelper, Helpers::ScopeHelper
Defined in:
lib/gdpr_admin/application_data_policy.rb

Direct Known Subclasses

PaperTrail::VersionDataPolicy

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Helpers::ScopeHelper

#scope_by_date

Methods included from Helpers::EraseHelper

#erase_fields

Methods included from Helpers::PaperTrailHelper

#anonymize_version_object, #anonymize_version_object_changes, #without_paper_trail

Methods included from Helpers::FieldAnonymizerHelper

#anonymize_field, #nilify, #nullify, #with_seed

Methods included from GdprAdmin::Anonymizers::InternetAnonymizer

#anonymize_email, #anonymize_ip, #anonymize_password, #mask_ip

Methods included from GdprAdmin::Anonymizers::ContactAnonymizer

#anonymize_city, #anonymize_country, #anonymize_country_code2, #anonymize_country_code3, #anonymize_phone_number, #anonymize_state, #anonymize_street_address, #anonymize_zip

Methods included from GdprAdmin::Anonymizers::CompanyAnonymizer

#anonymize_company

Methods included from GdprAdmin::Anonymizers::NameAnonymizer

#anonymize_first_name, #anonymize_last_name, #anonymize_name

Methods included from Helpers::DataPolicyHelper

#model_data_policy_class, #skip_data_policy!, #skip_record!

Constructor Details

#initialize(request) ⇒ ApplicationDataPolicy

Returns a new instance of ApplicationDataPolicy.



27
28
29
# File 'lib/gdpr_admin/application_data_policy.rb', line 27

def initialize(request)
  @request = request
end

Class Attribute Details

.before_process_hooksObject (readonly)

Returns the value of attribute before_process_hooks.



10
11
12
# File 'lib/gdpr_admin/application_data_policy.rb', line 10

def before_process_hooks
  @before_process_hooks
end

.before_process_record_hooksObject (readonly)

Returns the value of attribute before_process_record_hooks.



10
11
12
# File 'lib/gdpr_admin/application_data_policy.rb', line 10

def before_process_record_hooks
  @before_process_record_hooks
end

Class Method Details

.before_process(method) ⇒ Object



12
13
14
15
# File 'lib/gdpr_admin/application_data_policy.rb', line 12

def before_process(method)
  @before_process_hooks ||= []
  @before_process_hooks << method
end

.before_process_record(method) ⇒ Object



17
18
19
20
# File 'lib/gdpr_admin/application_data_policy.rb', line 17

def before_process_record(method)
  @before_process_record_hooks ||= []
  @before_process_record_hooks << method
end

.process(request) ⇒ Object



22
23
24
# File 'lib/gdpr_admin/application_data_policy.rb', line 22

def process(request)
  new(request).process
end

Instance Method Details

#erase(_record) ⇒ Object

Raises:

  • (NotImplementedError)


39
40
41
# File 'lib/gdpr_admin/application_data_policy.rb', line 39

def erase(_record)
  raise NotImplementedError
end

#export(_record) ⇒ Object

Raises:

  • (NotImplementedError)


35
36
37
# File 'lib/gdpr_admin/application_data_policy.rb', line 35

def export(_record)
  raise NotImplementedError
end

#processObject



43
44
45
46
47
48
49
50
# File 'lib/gdpr_admin/application_data_policy.rb', line 43

def process
  GdprAdmin.config.tenant_adapter.with_tenant(request.tenant) do
    run_preprocessors
    process_scope
  rescue SkipDataPolicyError
    nil
  end
end

#process_scopeObject



52
53
54
55
56
# File 'lib/gdpr_admin/application_data_policy.rb', line 52

def process_scope
  policy_scope.find_each do |record|
    process_record(record)
  end
end

#scopeObject



31
32
33
# File 'lib/gdpr_admin/application_data_policy.rb', line 31

def scope
  skip_data_policy!
end