Sha256: 4610da24c0c7af38bb819d68cd8bb759860ee2c0e7bc818663244764341b50ec

Contents?: true

Size: 461 Bytes

Versions: 13

Compression:

Stored size: 461 Bytes

Contents

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

13 entries across 13 versions & 1 rubygems

Version Path
split-1.3.2 lib/split/extensions/string.rb
split-1.3.1 lib/split/extensions/string.rb
split-1.3.0 lib/split/extensions/string.rb
split-1.2.1 lib/split/extensions/string.rb
split-1.2.0 lib/split/extensions/string.rb
split-1.1.0 lib/split/extensions/string.rb
split-1.0.0 lib/split/extensions/string.rb
split-0.8.0 lib/split/extensions/string.rb
split-0.7.3 lib/split/extensions/string.rb
split-0.7.2 lib/split/extensions/string.rb
split-0.7.1 lib/split/extensions/string.rb
split-0.7.0 lib/split/extensions/string.rb
split-0.6.6 lib/split/extensions/string.rb