Class: Insta::Redaction::Applicator
- Inherits:
-
Object
- Object
- Insta::Redaction::Applicator
- Defined in:
- lib/insta/redaction/applicator.rb,
sig/insta/redaction/applicator.rbs
Class Method Summary collapse
-
.apply(value, redactions) ⇒ Object
: (untyped, Hash[String, untyped]?) -> untyped.
Class Method Details
.apply(value, redactions) ⇒ Object
: (untyped, Hash[String, untyped]?) -> untyped
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/insta/redaction/applicator.rb', line 7 def self.apply(value, redactions) return value if redactions.nil? || redactions.empty? unless value.is_a?(Hash) || value.is_a?(Array) raise ArgumentError, "Redactions require structured data (Hash or Array), got #{value.class}. " \ "Use a structured serializer like `serializer: :json` or `serializer: :yaml` with Hash/Array values." end duped = deep_dup(value) parsed = redactions.transform_keys { |key| Selector.new(key) } walk(duped, [], parsed) duped end |