Class: SemanticLoggerEcsAddon::Utils::Hash
- Inherits:
-
Hash
- Object
- Hash
- SemanticLoggerEcsAddon::Utils::Hash
- Defined in:
- lib/semantic_logger_ecs_addon/utils/hash.rb
Instance Method Summary collapse
-
#extract!(*keys) ⇒ Object
With thanks to github.com/rails/rails/blob/83217025a171593547d1268651b446d3533e2019/activesupport/lib/active_support/core_ext/hash/slice.rb#L24 Removes and returns the key/value pairs matching the given keys.
Instance Method Details
#extract!(*keys) ⇒ Object
With thanks to github.com/rails/rails/blob/83217025a171593547d1268651b446d3533e2019/activesupport/lib/active_support/core_ext/hash/slice.rb#L24 Removes and returns the key/value pairs matching the given keys.
hash = { a: 1, b: 2, c: 3, d: 4 }
hash.extract!(:a, :b) # => {:a=>1, :b=>2}
hash # => {:c=>3, :d=>4}
12 13 14 15 16 |
# File 'lib/semantic_logger_ecs_addon/utils/hash.rb', line 12 def extract! *keys keys.each_with_object self.class.new do |key, result| result[key] = delete key if key? key end end |