Skip to content

Commit

Permalink
Fix the constantize method
Browse files Browse the repository at this point in the history
Initially I've thought about adding a [managed string inflector](https://github.com/dry-rb/dry-inflector/blob/main/lib/dry/inflector.rb#L88) as a dependency, but there is no need for that just to use this single method.

Instead I've replaced the  with the  to avoid additional dependencies.
Resolves: #407
  • Loading branch information
swilgosz authored and marcelolx committed Sep 22, 2022
1 parent 8ad1f74 commit 02fc716
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
4 changes: 1 addition & 3 deletions lib/sidekiq-scheduler/schedule.rb
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,7 @@ def infer_queue(klass)
end

def try_to_constantize(klass)
klass.is_a?(String) ? klass.constantize : klass
rescue NameError
klass
SidekiqScheduler::Utils.try_to_constantize(klass)
end
end
end
2 changes: 1 addition & 1 deletion lib/sidekiq-scheduler/utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def self.symbolize_keys(object)
#
# @return [Class] the class corresponding to the klass param
def self.try_to_constantize(klass)
klass.is_a?(String) ? klass.constantize : klass
klass.is_a?(String) ? Object.const_get(klass) : klass
rescue NameError
klass
end
Expand Down

0 comments on commit 02fc716

Please sign in to comment.