Sha256: 1719af77acd6e3de58d70f518697e70980695ec7cb88f64436efd9926a1990c1

Contents?: true

Size: 493 Bytes

Versions: 3

Compression:

Stored size: 493 Bytes

Contents

# frozen_string_literal: true

class String
  # Constatntize is often provided by ActiveSupport, but ActiveSupport is not a dependency of Split.
  unless method_defined?(:constantize)
    def constantize
      names = self.split('::')
      names.shift if names.empty? || names.first.empty?

      constant = Object
      names.each do |name|
        constant = constant.const_defined?(name) ? constant.const_get(name) : constant.const_missing(name)
      end
      constant
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
split-4.0.1 lib/split/extensions/string.rb
split-4.0.0.pre2 lib/split/extensions/string.rb
split-4.0.0.pre lib/split/extensions/string.rb