From f6453e0f479890624c2f43543746fa54a82c7eec Mon Sep 17 00:00:00 2001 From: Holger Just Date: Thu, 16 Feb 2017 21:55:08 +0100 Subject: [PATCH] Replace overwritten conversion methods with `implicit` method to retain expected method behavior --- lib/rackstash/fields/array.rb | 4 ++-- lib/rackstash/fields/hash.rb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/rackstash/fields/array.rb b/lib/rackstash/fields/array.rb index 2de16bd..8089385 100644 --- a/lib/rackstash/fields/array.rb +++ b/lib/rackstash/fields/array.rb @@ -112,7 +112,7 @@ module Rackstash # object (when given). # @return [self] def concat(array, scope: nil) - array = Array(normalize(array, wrap: false, scope: scope)) + array = implicit(normalize(array, wrap: false, scope: scope)) @raw.concat(array) self end @@ -160,7 +160,7 @@ module Rackstash private - def Array(obj) + def implicit(obj) return obj.to_ary if obj.respond_to?(:to_ary) raise TypeError, "no implicit conversion of #{obj.class} into Array" end diff --git a/lib/rackstash/fields/hash.rb b/lib/rackstash/fields/hash.rb index 220b6af..c322b11 100644 --- a/lib/rackstash/fields/hash.rb +++ b/lib/rackstash/fields/hash.rb @@ -158,7 +158,7 @@ module Rackstash # # @return [self] def merge!(hash, force: true, scope: nil) - hash = Hash(normalize(hash, scope: scope, wrap: false)) + hash = implicit(normalize(hash, scope: scope, wrap: false)) if force forbidden = @forbidden_keys & hash.keys @@ -223,7 +223,7 @@ module Rackstash private - def Hash(obj) + def implicit(obj) return obj.to_hash if obj.respond_to?(:to_hash) raise TypeError, "no implicit conversion of #{obj.class} into Hash" end