Class/Module Index [+]

Quicksearch

Mongoid::Extensions::String::Inflections

This module contains convenience methods for string inflection and conversion.

Constants

CHAR_CONV

Represents how special characters will get converted when creating a composite key that should be unique and part of a url.

REVERSALS

Public Instance Methods

collectionize() click to toggle source

Convert the string to a collection friendly name.

@example Collectionize the string.

"namespace/model".collectionize

@return [ String ] The string in collection friendly form.

# File lib/mongoid/extensions/string/inflections.rb, line 66
def collectionize
  tableize.gsub("/", "_")
end
identify() click to toggle source

Convert this string to a key friendly string.

@example Convert to key.

"testing".identify

@return [ String ] The key friendly string.

# File lib/mongoid/extensions/string/inflections.rb, line 76
def identify
  if Mongoid.parameterize_keys
    key = ""
    each_char { |c| key += (CHAR_CONV[c] || c.downcase) }; key
  else
    self
  end
end
invert() click to toggle source

Get the inverted sorting option.

@example Get the inverted option.

"asc".invert

@return [ String ] The string inverted.

# File lib/mongoid/extensions/string/inflections.rb, line 91
def invert
  REVERSALS[self]
end
reader() click to toggle source

Get the string as a getter string.

@example Get the reader/getter

"model=".reader

@return [ String ] The string stripped of “=”.

# File lib/mongoid/extensions/string/inflections.rb, line 101
def reader
  writer? ? gsub("=", "") : self
end
writer?() click to toggle source

Is this string a writer?

@example Is the string a setter method?

"model=".writer?

@return [ true, false ] If the string contains “=”.

# File lib/mongoid/extensions/string/inflections.rb, line 111
def writer?
  include?("=")
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.