This module contains convenience methods for string inflection and conversion.
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
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
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
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
Generated with the Darkfish Rdoc Generator 2.