Sha256: 21d507fb58a1829c6a9b85747a1d5a7ba3119b218b96ed1f0506632cc608d4cf

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.4 lib/split/extensions/string.rb
split-4.0.3 lib/split/extensions/string.rb
split-4.0.2 lib/split/extensions/string.rb