Sha256: c9416b39cabd9c4481ba0920e99e39c240ec7ca4ca31e3da92ebe65db29606df

Contents?: true

Size: 462 Bytes

Versions: 7

Compression:

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

7 entries across 7 versions & 1 rubygems

Version Path
split-0.6.5 lib/split/extensions/string.rb
split-0.6.4 lib/split/extensions/string.rb
split-0.6.3 lib/split/extensions/string.rb
split-0.6.2 lib/split/extensions/string.rb
split-0.6.1 lib/split/extensions/string.rb
split-0.6.0 lib/split/extensions/string.rb
split-0.5.0 lib/split/extensions/string.rb