Class: PaperTrailDiff::IgnorePolicy
- Inherits:
-
Object
- Object
- PaperTrailDiff::IgnorePolicy
- Defined in:
- lib/paper_trail_diff/configuration.rb,
sig/generated/paper_trail_diff/configuration.rbs
Overview
Immutable rules for globally and path-specifically excluded attributes.
Constant Summary collapse
- ROOT_PATH =
'$'- VALID_KEYS =
%w[all paths].freeze
Instance Attribute Summary collapse
- #all ⇒ Array[String] readonly
- #paths ⇒ Hash[String, Array[String]] readonly
Class Method Summary collapse
-
.build(value, association_paths:) ⇒ IgnorePolicy
: (untyped, association_paths: Array) -> IgnorePolicy.
Instance Method Summary collapse
-
#attributes_for(path) ⇒ Array[String]
: (String) -> Array.
-
#initialize(all:, paths:) ⇒ IgnorePolicy
constructor
: (all: Array, paths: Hash[String, Array[String]]) -> void.
Constructor Details
#initialize(all:, paths:) ⇒ IgnorePolicy
: (all: Array, paths: Hash[String, Array[String]]) -> void
158 159 160 161 162 |
# File 'lib/paper_trail_diff/configuration.rb', line 158 def initialize(all:, paths:) @all = all.dup.freeze @paths = paths.dup.freeze freeze end |
Instance Attribute Details
#all ⇒ Array[String] (readonly)
154 155 156 |
# File 'lib/paper_trail_diff/configuration.rb', line 154 def all @all end |
#paths ⇒ Hash[String, Array[String]] (readonly)
155 156 157 |
# File 'lib/paper_trail_diff/configuration.rb', line 155 def paths @paths end |
Class Method Details
.build(value, association_paths:) ⇒ IgnorePolicy
: (untyped, association_paths: Array) -> IgnorePolicy
89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/paper_trail_diff/configuration.rb', line 89 def build(value, association_paths:) return new(all: normalize_names(value, context: 'ignore'), paths: {}) if value.is_a?(Array) unless value.is_a?(Hash) raise ConfigurationError, 'ignore: must be an array or a hash with all: and paths:' end = (value) empty_paths = {} #: Hash[untyped, untyped] new( all: normalize_names(.fetch('all', []), context: 'ignore[:all]'), paths: normalize_paths(.fetch('paths', empty_paths), association_paths) ) end |