Module: Redaction

Defined in:
lib/redaction.rb,
lib/redaction/railtie.rb,
lib/redaction/version.rb,
lib/redaction/redactor.rb,
lib/redaction/redactable.rb,
lib/redaction/types/base.rb,
lib/redaction/types/html.rb,
lib/redaction/types/name.rb,
lib/redaction/types/text.rb,
lib/redaction/types/basic.rb,
lib/redaction/types/email.rb,
lib/redaction/types/phone.rb,
lib/redaction/types/basic_html.rb

Defined Under Namespace

Modules: Redactable, Types Classes: ProductionEnvironmentError, Railtie, Redactor

Constant Summary collapse

VERSION =
"0.4.0"

Class Method Summary collapse

Class Method Details

.configObject



3
4
5
# File 'lib/redaction/railtie.rb', line 3

def config
  @config ||= Railtie.config.redaction
end

.find(redactor_type) ⇒ Object



27
28
29
30
31
32
33
# File 'lib/redaction.rb', line 27

def self.find(redactor_type)
  if redactor_type.respond_to?(:call)
    redactor_type
  else
    "Redaction::Types::#{redactor_type.to_s.camelize}".safe_constantize || Redaction::Types::Base
  end
end

.redact!(models: nil) ⇒ Object



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

def self.redact!(models: nil)
  Redactor.new(models: models).redact!
end

.redactable_modelsObject



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

def self.redactable_models
  ApplicationRecord.subclasses.select { |descendant| descendant.has_redacted_content? }
end