Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 6 additions & 14 deletions lib/raven/utils/deep_merge.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# rubocop:disable all
module Raven
module Utils
# ported from ActiveSupport
Expand All @@ -8,23 +7,16 @@ def self.deep_merge(hash, other_hash, &block)
end

def self.deep_merge!(hash, other_hash, &block)
other_hash.each_pair do |current_key, other_value|
this_value = hash[current_key]

hash[current_key] = if this_value.is_a?(Hash) && other_value.is_a?(Hash)
deep_merge(this_value, other_value, &block)
hash.merge!(other_hash) do |key, this_val, other_val|
if this_val.is_a?(Hash) && other_val.is_a?(Hash)
deep_merge(this_val, other_val, &block)
elsif block_given?
block.call(key, this_val, other_val)
else
if block_given? && key?(current_key)
block.call(current_key, this_value, other_value)
else
other_value
end
other_val
end
end

hash
end
end
end
end
# rubocop:enable all
2 changes: 1 addition & 1 deletion spec/raven/processors/utf8conversion_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
data = ["\xE2\x9C\x89 Hello".force_encoding(Encoding::ASCII_8BIT).freeze]

results = @processor.process(data)

expect(JSON.generate(results)).to eq("[\"✉ Hello\"]")
end
end