Last active
September 10, 2016 23:37
-
-
Save sshaw/b408f89b4128ddbeac28d2596fae6e39 to your computer and use it in GitHub Desktop.
String#to_pluralizer: Create a pluralization Proc from a String
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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