Class: Hash

Inherits:
Object
  • Object
show all
Defined in:
lib/logstash/filters/rest.rb

Overview

Monkey Patch hsh with a recursive compact and deep freeze

Instance Method Summary collapse

Instance Method Details

#compactObject



9
10
11
# File 'lib/logstash/filters/rest.rb', line 9

def compact
  delete_if { |_k, v| v.respond_to?(:each) ? v.compact.empty? : v.nil? }
end

#deep_freezeObject



13
14
15
16
# File 'lib/logstash/filters/rest.rb', line 13

def deep_freeze
  each { |_k, v| v.deep_freeze if v.respond_to? :deep_freeze }
  freeze
end