Skip to content

Instantly share code, notes, and snippets.

@sshaw sshaw/to_pluralizer.rb
Last active Sep 10, 2016

Embed
What would you like to do?
String#to_pluralizer: Create a pluralization Proc from a String
require "active_support/core_ext/string/inflections"
class String
def to_pluralizer
->(*a) { pluralize(*a) }
end
end
__END__
CUSTOMER = "customer".to_pluralizer
CUSTOMER[10] # customers
PRODUCT = "product".to_pluralizer
PRODUCT[10] # products
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.