instance method
apply_inflections
Ruby on Rails 3.2.22.5
Since v3.2.22.5 PrivateSignature
apply_inflections(word, rules)
Applies inflection rules for singularize and pluralize.
Examples:
apply_inflections("post", inflections.plurals) # => "posts" apply_inflections("posts", inflections.singulars) # => "post"
Parameters
-
wordreq -
rulesreq
Source
# File activesupport/lib/active_support/inflector/methods.rb, line 310
def apply_inflections(word, rules)
result = word.to_s.dup
if word.empty? || inflections.uncountables.any? { |inflection| result =~ /\b#{inflection}\Z/i }
result
else
rules.each { |(rule, replacement)| break if result.gsub!(rule, replacement) }
result
end
end
Defined in activesupport/lib/active_support/inflector/methods.rb line 310
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveSupport::Inflector