Sha256: 19231748b702f76950bd2e84672414860a981997a40534730a80f0d7be0da698

Contents?: true

Size: 559 Bytes

Versions: 2

Compression:

Stored size: 559 Bytes

Contents

class String
  def classify
    if defined?(ActiveSupport::Inflector)
      ActiveSupport::Inflector.classify(self)
    else
      self.gsub(/(_|-)/, ' ').
        split(' ').each do |word|
        word.capitalize!
      end.join
    end
  end

  def constantize
    if defined?(ActiveSupport::Inflector)
      ActiveSupport::Inflector.constantize(self)
    else
      Object.const_get(self)
    end
  end

  def singularize
    if defined?(ActiveSupport::Inflector)
      ActiveSupport::Inflector.singularize(self, :en)
    else
      self
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fixture_overlord-0.1.9 lib/fixture_overlord/string_extension.rb
fixture_overlord-0.1.8 lib/fixture_overlord/string_extension.rb