Extract humanize method from Extlib::Inflection to CouchRest.humanize, so that Extlib::Inflection dependency can be removed
This commit is contained in:
parent
ef8933432a
commit
d9417f3915
4 changed files with 15 additions and 3 deletions
|
@ -69,6 +69,18 @@ module CouchRest
|
|||
Object.module_eval("::#{$1}", __FILE__, __LINE__)
|
||||
end
|
||||
|
||||
# extracted from Extlib
|
||||
#
|
||||
# Capitalizes the first word and turns underscores into spaces and strips _id.
|
||||
# Like titleize, this is meant for creating pretty output.
|
||||
#
|
||||
# @example
|
||||
# "employee_salary" #=> "Employee salary"
|
||||
# "author_id" #=> "Author"
|
||||
def humanize(lower_case_and_underscored_word)
|
||||
lower_case_and_underscored_word.to_s.gsub(/_id$/, "").gsub(/_/, " ").capitalize
|
||||
end
|
||||
|
||||
# todo, make this parse the url and instantiate a Server or Database instance
|
||||
# depending on the specificity.
|
||||
def new(*opts)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue