From 9af6de8d365d5d53ec0525e510376176642bd72e Mon Sep 17 00:00:00 2001 From: Max Melentiev Date: Wed, 21 Feb 2018 19:49:09 +0300 Subject: [PATCH] Avoid Hash#transform_values. Fixes #63 --- lib/telegram/bot/config_methods.rb | 3 +-- lib/telegram/bot/updates_controller/rspec_helpers.rb | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/telegram/bot/config_methods.rb b/lib/telegram/bot/config_methods.rb index 611de4f..3e31688 100644 --- a/lib/telegram/bot/config_methods.rb +++ b/lib/telegram/bot/config_methods.rb @@ -1,5 +1,4 @@ require 'active_support/core_ext/hash/keys' -require 'active_support/core_ext/hash/transform_values' require 'active_support/core_ext/hash/indifferent_access' module Telegram @@ -43,7 +42,7 @@ module Telegram # Hash of botan clients made from #bots. def botans - @botans ||= bots.transform_values(&:botan) + @botans ||= bots.map { |k, v| [k, v.botan] }.to_h end # Returns config for .bots method. By default uses `telegram['bots']` section diff --git a/lib/telegram/bot/updates_controller/rspec_helpers.rb b/lib/telegram/bot/updates_controller/rspec_helpers.rb index 1a4981a..1145a61 100644 --- a/lib/telegram/bot/updates_controller/rspec_helpers.rb +++ b/lib/telegram/bot/updates_controller/rspec_helpers.rb @@ -35,7 +35,7 @@ RSpec.shared_context 'telegram/bot/updates_controller' do def deep_stringify(input) case input when Array then input.map(&method(__callee__)) - when Hash then input.transform_keys(&:to_s).transform_values(&method(__callee__)) + when Hash then input.map { |k, v| [k.to_s, deep_stringify(v)] }.to_h else input end end