зеркало из
https://github.com/glebtv/telegram-bot.git
synced 2026-09-07 19:35:52 +03:00
Avoid Hash#transform_values. Fixes #63
Этот коммит содержится в:
@@ -1,5 +1,4 @@
|
|||||||
require 'active_support/core_ext/hash/keys'
|
require 'active_support/core_ext/hash/keys'
|
||||||
require 'active_support/core_ext/hash/transform_values'
|
|
||||||
require 'active_support/core_ext/hash/indifferent_access'
|
require 'active_support/core_ext/hash/indifferent_access'
|
||||||
|
|
||||||
module Telegram
|
module Telegram
|
||||||
@@ -43,7 +42,7 @@ module Telegram
|
|||||||
|
|
||||||
# Hash of botan clients made from #bots.
|
# Hash of botan clients made from #bots.
|
||||||
def botans
|
def botans
|
||||||
@botans ||= bots.transform_values(&:botan)
|
@botans ||= bots.map { |k, v| [k, v.botan] }.to_h
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns config for .bots method. By default uses `telegram['bots']` section
|
# Returns config for .bots method. By default uses `telegram['bots']` section
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ RSpec.shared_context 'telegram/bot/updates_controller' do
|
|||||||
def deep_stringify(input)
|
def deep_stringify(input)
|
||||||
case input
|
case input
|
||||||
when Array then input.map(&method(__callee__))
|
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
|
else input
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user