lib/runger/ext/string_constantize.rb in runger_config-4.0.0 vs lib/runger/ext/string_constantize.rb in runger_config-5.0.0

- old
+ new

@@ -1,24 +1,21 @@ # frozen_string_literal: true -module Runger - module Ext - # Add simple safe_constantize method to String - module StringConstantize - refine String do - def safe_constantize - names = split("::") +# Add simple safe_constantize method to String +module Runger::Ext::StringConstantize + refine String do + def safe_constantize + names = split('::') - return nil if names.empty? + return nil if names.empty? - # Remove the first blank element in case of '::ClassName' notation. - names.shift if names.size > 1 && names.first.empty? + # Remove the first blank element in case of '::ClassName' notation. + names.shift if names.size > 1 && names.first.empty? - names.inject(Object) do |constant, name| - break if constant.nil? - constant.const_get(name, false) if constant.const_defined?(name, false) - end - end + names.inject(Object) do |constant, name| + break if constant.nil? + + constant.const_get(name, false) if constant.const_defined?(name, false) end end end end