Class: PolicyManager::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/policy_manager/config.rb

Class Method Summary collapse

Class Method Details

.add_portability_rule(opts = {}, &block) ⇒ Object



73
74
75
# File 'lib/policy_manager/config.rb', line 73

def self.add_portability_rule(opts={}, &block)
  @@portability_rules << PolicyManager::PortabilityRule.new(opts, &block)
end

.add_rule(opts = {}, &block) ⇒ Object



69
70
71
# File 'lib/policy_manager/config.rb', line 69

def self.add_rule(opts={}, &block)
  @@rules << PolicyManager::Rule.new(opts, &block)
end

.add_script(opts = {}, &block) ⇒ Object



77
78
79
# File 'lib/policy_manager/config.rb', line 77

def self.add_script(opts={}, &block)
  @@scripts << PolicyManager::Script.new(opts, &block)
end

.admin_email(user) ⇒ Object



36
37
38
# File 'lib/policy_manager/config.rb', line 36

def self.admin_email(user)
  @@admin_email_inbox.is_a?(Proc) ? @@admin_email_inbox.call(user) : @@admin_email_inbox
end

.error_notifier_method(error) ⇒ Object



31
32
33
34
# File 'lib/policy_manager/config.rb', line 31

def self.error_notifier_method(error)
  puts error
  @@error_notifier.call(error) unless @@error_notifier.blank?
end

.exporter=(opts) ⇒ Object



40
41
42
# File 'lib/policy_manager/config.rb', line 40

def self.exporter=(opts)
  @@exporter = Exporter.new(opts)
end

.has_different_admin_user_resource?Boolean

Returns:

  • (Boolean)


53
54
55
# File 'lib/policy_manager/config.rb', line 53

def self.has_different_admin_user_resource?
  user_resource != admin_user_resource
end

.is_admin?(user) ⇒ Boolean

Returns:

  • (Boolean)


44
45
46
47
48
49
50
51
# File 'lib/policy_manager/config.rb', line 44

def self.is_admin?(user)
  if has_different_admin_user_resource?
    user.is_a? admin_user_resource
  else
    raise Rails.logger.error("GDPR ERROR! please add is_admin_method to your gdpr initializer") if @@is_admin_method.blank?
    @@is_admin_method.call(user)
  end
end

.portability_rulesObject



65
66
67
# File 'lib/policy_manager/config.rb', line 65

def self.portability_rules
  @@portability_rules ||= []
end

.rulesObject



61
62
63
# File 'lib/policy_manager/config.rb', line 61

def self.rules
  @@rules ||= []
end

.setup {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/policy_manager/config.rb', line 16

def self.setup
  @@rules = []
  @@portability_rules = []
  @@portability_templates = []
  @@scripts = []

  yield self

  # sets this defaults after configuration
  @@user_resource ||= 'User'
  @@admin_user_resource ||= @@user_resource

  self
end

.user_language(user) ⇒ Object



57
58
59
# File 'lib/policy_manager/config.rb', line 57

def self.user_language(user)
  @@user_language_method.call(user) rescue :en
end