module Anony::Config

Configuration which modifies how the gem will behave in your application. It's recommended practice to configure this in an initializer.

@example

# config/initializers/anony.rb
require "anony"

Anony::Config.ignore_fields(:id)

Public Class Methods

ignore?(field) click to toggle source

@!visibility private

# File lib/anony/config.rb, line 18
def self.ignore?(field)
  # In this case, we want to support literal matches, regular expressions and blocks,
  # all of which are helpfully handled by Object#===.
  #
  # rubocop:disable Style/CaseEquality
  ignores.any? { |rule| rule === field }
  # rubocop:enable Style/CaseEquality
end
ignore_fields(*fields) click to toggle source

A list of database or model properties to be ignored when anonymising. This is helpful in Rails applications when there are common columns such as `id`, `created_at` and `updated_at`, which we would never want to try and anonymise.

By default, this is an empty collection (i.e. no fields are ignored).

@param [Array<Symbol>] fields A list of fields names to ignore. @example Ignoring common Rails fields

Anony::Config.ignore_fields(:id, :created_at, :updated_at)
# File lib/anony/config.rb, line 36
def self.ignore_fields(*fields)
  self.ignores = Array(fields)
end