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
ab-split-1.0.2 lib/split/extensions/string.rb
ab-split-1.0.1 lib/split/extensions/string.rb
ab-split-1.0.0 lib/split/extensions/string.rb
split-3.4.1 lib/split/extensions/string.rb
split-3.4.0 lib/split/extensions/string.rb
split-3.3.2 lib/split/extensions/string.rb
split-3.3.1 lib/split/extensions/string.rb
split-3.3.0 lib/split/extensions/string.rb
split-3.2.0 lib/split/extensions/string.rb
split-3.1.1 lib/split/extensions/string.rb
split-3.1.0 lib/split/extensions/string.rb
split-3.0.0 lib/split/extensions/string.rb
split-2.2.0 lib/split/extensions/string.rb
split-2.1.0 lib/split/extensions/string.rb
split-2.0.0 lib/split/extensions/string.rb
split-1.7.0 lib/split/extensions/string.rb
split-1.6.0 lib/split/extensions/string.rb
split-1.5.0 lib/split/extensions/string.rb
split-1.4.5 lib/split/extensions/string.rb
split-1.4.4 lib/split/extensions/string.rb