Class: Agentlog::Compactor
- Inherits:
-
Object
- Object
- Agentlog::Compactor
- Defined in:
- lib/agentlog/compactor.rb
Instance Method Summary collapse
- #compact(value, key: nil) ⇒ Object
-
#initialize(configuration) ⇒ Compactor
constructor
A new instance of Compactor.
Constructor Details
#initialize(configuration) ⇒ Compactor
Returns a new instance of Compactor.
8 9 10 11 |
# File 'lib/agentlog/compactor.rb', line 8 def initialize(configuration) @configuration = configuration @preserve_keys = configuration.preserve_keys.to_set { |key| normalize_key(key) } end |
Instance Method Details
#compact(value, key: nil) ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/agentlog/compactor.rb', line 13 def compact(value, key: nil) return compact_scalar(value, key:) unless value.is_a?(Hash) || value.is_a?(Array) case value when Hash compact_hash(value) when Array compact_array(value, key:) end end |