Class: Julewire::Redaction::Processor
- Inherits:
-
Object
- Object
- Julewire::Redaction::Processor
- Defined in:
- lib/julewire/redaction/processor.rb
Instance Method Summary collapse
- #call(draft) ⇒ Object
-
#initialize(filters = Redaction.config.filters, mask: Redaction.config.mask, max_array_items: Redaction.config.max_array_items, max_depth: Redaction.config.max_depth, max_hash_keys: Redaction.config.max_hash_keys, max_string_bytes: Redaction.config.max_string_bytes, string_values: Redaction.config.string_values, authorization_header: Redaction.config.authorization_header) ⇒ Processor
constructor
A new instance of Processor.
Constructor Details
#initialize(filters = Redaction.config.filters, mask: Redaction.config.mask, max_array_items: Redaction.config.max_array_items, max_depth: Redaction.config.max_depth, max_hash_keys: Redaction.config.max_hash_keys, max_string_bytes: Redaction.config.max_string_bytes, string_values: Redaction.config.string_values, authorization_header: Redaction.config.authorization_header) ⇒ Processor
Returns a new instance of Processor.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/julewire/redaction/processor.rb', line 11 def initialize( filters = Redaction.config.filters, mask: Redaction.config.mask, max_array_items: Redaction.config.max_array_items, max_depth: Redaction.config.max_depth, max_hash_keys: Redaction.config.max_hash_keys, max_string_bytes: Redaction.config.max_string_bytes, string_values: Redaction.config.string_values, authorization_header: Redaction.config. ) @matcher = Matcher.new(filters) @blocks = @matcher.blocks @mask = mask.to_s @max_array_items = Core::Validation.validate_integer_limit!(max_array_items, name: :max_array_items) @max_depth = Core::Validation.validate_integer_limit!(max_depth, name: :max_depth, positive: true) @max_hash_keys = Core::Validation.validate_integer_limit!(max_hash_keys, name: :max_hash_keys) @max_string_bytes = Core::Validation.validate_integer_limit!(max_string_bytes, name: :max_string_bytes) @string_redactor = if string_values StringRedactor.new( matcher: @matcher, mask: @mask, authorization_header: ) end @redact_keys = !@matcher.empty? @redact_scalars = @string_redactor || !@blocks.empty? @enabled = @redact_keys || @redact_scalars @record_transform = Core::Processing::RecordFieldTransform.new( max_array_items: @max_array_items, max_depth: @max_depth, max_hash_keys: @max_hash_keys, max_string_bytes: @max_string_bytes, preserve_top_level_keys: PRESERVED_TOP_LEVEL_KEYS, track_paths: @matcher.path_dependent? ) end |
Instance Method Details
#call(draft) ⇒ Object
48 49 50 51 52 53 |
# File 'lib/julewire/redaction/processor.rb', line 48 def call(draft) validate_draft!(draft) return draft unless @enabled draft.transform_record! { redact_record(it) } end |