lib/json_reducer/mask.rb in json_reducer-0.1.0 vs lib/json_reducer/mask.rb in json_reducer-1.1.0

- old
+ new

@@ -1,9 +1,9 @@ module JsonReducer class Mask - def initialize(schema) - @schema = parse_record(schema) + def initialize(key) + @schema = JsonReducer::Schemas.instance.get(key) end def apply(payload) payload = parse_record(payload).dup apply!(payload, @schema) @@ -14,10 +14,9 @@ private def apply!(payload, schema) return if schema.dig('properties').nil? - # sliced = payload.slice!(*schema['properties'].keys) sliced = slice!(payload, schema['properties'].keys) handle(schema['properties'], sliced) end def handle(properties, payload)