Class: GdprAdmin::Request

Inherits:
ApplicationRecord show all
Defined in:
app/models/gdpr_admin/request.rb

Constant Summary collapse

VALID_STATUS_TRANSITIONS =
{
  pending: %i[processing canceled],
  processing: %i[completed failed],
  completed: [],
  failed: %i[pending],
  canceled: %i[],
}.freeze

Instance Method Summary collapse

Instance Method Details

#cancel!Object



38
39
40
# File 'app/models/gdpr_admin/request.rb', line 38

def cancel!
  canceled!
end

#erase?Boolean

Returns:

  • (Boolean)


58
59
60
# File 'app/models/gdpr_admin/request.rb', line 58

def erase?
  erase_data? || erase_subject?
end

#export?Boolean

Returns:

  • (Boolean)


62
63
64
# File 'app/models/gdpr_admin/request.rb', line 62

def export?
  export_subject?
end

#lock_strategy(&block) ⇒ Object



70
71
72
73
74
75
# File 'app/models/gdpr_admin/request.rb', line 70

def lock_strategy(&block)
  return with_lock(&block) if GdprAdmin.config.rollback_on_failure
  return with_advisory_lock(to_global_id.to_s, &block) if respond_to?(:with_advisory_lock)

  yield
end

#process!Object



42
43
44
45
46
47
48
49
50
51
52
# File 'app/models/gdpr_admin/request.rb', line 42

def process!
  GdprAdmin.load_data_policies
  reload.lock_strategy { processing! }
  lock_strategy do
    process_policies
    completed!
  end
rescue StandardError
  failed!
  raise
end

#schedule_processingObject



66
67
68
# File 'app/models/gdpr_admin/request.rb', line 66

def schedule_processing
  RequestProcessorJob.set(wait: grace_period).perform_later(self)
end

#subject_request?Boolean

Returns:

  • (Boolean)


54
55
56
# File 'app/models/gdpr_admin/request.rb', line 54

def subject_request?
  export_subject? || erase_subject?
end