Sha256: 69502d697d9bf90474578c6b0a5f7f04286101c0c0464fda7dc0834585842a6c

Contents?: true

Size: 435 Bytes

Versions: 29

Compression:

Stored size: 435 Bytes

Contents

# This extends String to add the +resourcerize+ method.
class String

  # Dasherizes and downcases a camelcased string. Used for Feed types.
  def resourcerize
    self.gsub(/([a-z])([A-Z])/, '\1-\2').downcase
  end

def constantize
    unless /\A(?:::)?([A-Z]\w*(?:::[A-Z]\w*)*)\z/ =~ self
      raise NameError, "#{self.inspect} is not a valid constant name!"
    end
    Object.module_eval("::#{$1}", __FILE__, __LINE__)
  end

end

Version data entries

29 entries across 29 versions & 4 rubygems

Version Path
databasedotcom-1.1.2 lib/databasedotcom/core_extensions/string_extensions.rb
databasedotcom-1.1.1 lib/databasedotcom/core_extensions/string_extensions.rb
databasedotcom-1.1.0 lib/databasedotcom/core_extensions/string_extensions.rb
databasedotcom-1.0.9 lib/databasedotcom/core_extensions/string_extensions.rb
databasedotcom-1.0.8 lib/databasedotcom/core_extensions/string_extensions.rb
databasedotcom-1.0.7 lib/databasedotcom/core_extensions/string_extensions.rb
databasedotcom-1.0.6 lib/databasedotcom/core_extensions/string_extensions.rb
databasedotcom-1.0.5 lib/databasedotcom/core_extensions/string_extensions.rb
databasedotcom-1.0.3 lib/databasedotcom/core_extensions/string_extensions.rb