Class: PiiSafeSchema::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/pii_safe_schema/configuration.rb

Constant Summary collapse

DEFAULT_IGNORE =
{
  schema_migrations: :*,
  ar_internal_metadata: :*,
}.freeze
KNOWN_DD_CLIENTS =
%w[DataDogClient Ws::Railway::Datadog].freeze

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



10
11
12
# File 'lib/pii_safe_schema/configuration.rb', line 10

def initialize
  @user_ignore = {}
end

Instance Method Details

#datadog_clientObject



29
30
31
32
33
34
# File 'lib/pii_safe_schema/configuration.rb', line 29

def datadog_client
  @datadog_client ||=
    KNOWN_DD_CLIENTS.find do |client|
      client.safe_constantize if defined?(client)
    end
end

#datadog_client=(client) ⇒ Object



23
24
25
26
27
# File 'lib/pii_safe_schema/configuration.rb', line 23

def datadog_client=(client)
  raise_config_error(:datadog_client) if client.present? && !client.respond_to?(:event)

  @datadog_client = client
end

#ignoreObject



19
20
21
# File 'lib/pii_safe_schema/configuration.rb', line 19

def ignore
  @user_ignore.merge(DEFAULT_IGNORE)
end

#ignore=(ignore_params) ⇒ Object



14
15
16
17
# File 'lib/pii_safe_schema/configuration.rb', line 14

def ignore=(ignore_params)
  validate_ignore(ignore_params)
  @user_ignore = ignore_params
end

#ignore_columnsObject



40
41
42
# File 'lib/pii_safe_schema/configuration.rb', line 40

def ignore_columns
  ignore.select { |_k, v| v.is_a?(Array) }
end

#ignore_tablesObject



36
37
38
# File 'lib/pii_safe_schema/configuration.rb', line 36

def ignore_tables
  ignore.select { |_k, v| v.to_s == '*' }.keys.map(&:to_s)
end