Sha256: d8a057289700c6dd682e104ccd0ca7ec4d34f8cb006e7d1379a188210a6f931e

Contents?: true

Size: 492 Bytes

Versions: 24

Compression:

Stored size: 492 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

24 entries across 24 versions & 2 rubygems

Version Path
split-1.4.3 lib/split/extensions/string.rb
split-1.4.2 lib/split/extensions/string.rb
split-1.4.1 lib/split/extensions/string.rb
split-1.4.0 lib/split/extensions/string.rb