Sha256: 8c5ff2ce120a1d8f0b21259d231d1d84bd70096f99d28086629122ef02953d15

Contents?: true

Size: 469 Bytes

Versions: 23

Compression:

Stored size: 469 Bytes

Contents

class Object
   #note: Object does not define Object#empty?
   def blank?
     respond_to?(:empty?) ? empty? : !self
   end
end

class String
  def constantize()
    camel_cased_word = self
    names = camel_cased_word.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

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
name-spotter-0.2.4 lib/name-spotter/monkey_patches.rb
name-spotter-0.2.3 lib/name-spotter/monkey_patches.rb
name-spotter-0.2.2 lib/name-spotter/monkey_patches.rb
name-spotter-0.2.1 lib/name-spotter/monkey_patches.rb
name-spotter-0.2.0 lib/name-spotter/monkey_patches.rb
name-spotter-0.1.11 lib/name-spotter/monkey_patches.rb
name-spotter-0.1.10 lib/name-spotter/monkey_patches.rb
name-spotter-0.1.9 lib/name-spotter/monkey_patches.rb
name-spotter-0.1.8 lib/name-spotter/monkey_patches.rb
name-spotter-0.1.7 lib/name-spotter/monkey_patches.rb
name-spotter-0.1.6 lib/name-spotter/monkey_patches.rb
name-spotter-0.1.5 lib/name-spotter/monkey_patches.rb
name-spotter-0.1.4 lib/name-spotter/monkey_patches.rb
name-spotter-0.1.3 lib/name-spotter/monkey_patches.rb
name-spotter-0.1.2 lib/name-spotter/monkey_patches.rb
name-spotter-0.1.1 lib/name-spotter/monkey_patches.rb
name-spotter-0.1.0 lib/name-spotter/monkey_patches.rb
name-spotter-0.0.7 lib/name-spotter/monkey_patches.rb
name-spotter-0.0.6 lib/name-spotter/monkey_patches.rb
name-spotter-0.0.5 lib/name-spotter/monkey_patches.rb