1
0
Fork 0
mirror of https://github.com/mperham/sidekiq.git synced 2022-11-09 13:52:34 -05:00

Prefer Hash#transform_keys & Regex#named_captures (#4491)

* Prefer Hash#transform_keys to stringify keys

* Prefer Regexp#named_captures to create hash for match data
This commit is contained in:
Akshay Birajdar 2020-03-16 02:02:25 +05:30 committed by GitHub
parent 2ac87ba839
commit 2bfd41117c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 4 deletions

View file

@ -154,7 +154,7 @@ module Sidekiq
def self.default_worker_options=(hash)
# stringify
@default_worker_options = default_worker_options.merge(Hash[hash.map { |k, v| [k.to_s, v] }])
@default_worker_options = default_worker_options.merge(hash.transform_keys(&:to_s))
end
def self.default_worker_options

View file

@ -95,7 +95,7 @@ module Sidekiq
else
path_match = path.match(matcher)
if path_match
Hash[path_match.names.map(&:to_sym).zip(path_match.captures)]
path_match.named_captures.transform_keys(&:to_sym)
end
end
end

View file

@ -48,8 +48,8 @@ module Sidekiq
# In practice, any option is allowed. This is the main mechanism to configure the
# options for a specific job.
def sidekiq_options(opts = {})
opts = Hash[opts.map { |k, v| [k.to_s, v] }] # stringify
self.sidekiq_options_hash = get_sidekiq_options.merge(Hash[opts.map { |k, v| [k.to_s, v] }])
opts = opts.transform_keys(&:to_s) # stringify
self.sidekiq_options_hash = get_sidekiq_options.merge(opts)
end
def sidekiq_retry_in(&block)