Sha256: d61b28c6f4eeac609338c235e5e03b50cf87dc486af31b2ac63e9e2b67b1a237
Contents?: true
Size: 973 Bytes
Versions: 1
Compression:
Stored size: 973 Bytes
Contents
# # Like the name suggests, helper methods for pluralization. # module PluralizeHelper require 'active_support' ENFORCE_PLURALS = true # # Determines if # word:: an input word # is singular. # Retutns truthy. # def singular?(word) ActiveSupport::Inflector.singularize(word) == word end # # If ENFORCE_PLURALS is true (default == true) # This enforces plural names for all collections # and returns 403 otherwise. # word:: collection name # def enforce_plural(word) # Mixing in the contol exclusion is strange here. # This can still coexist with a /controls endpoint but may be confusing. # I don't want to think about the possibility that we don't have plural # collections and happen to have a collision with a control collection yet. if word != 'control' && ENFORCE_PLURALS && singular?(word) halt 403, 'only plural collection names allowed' end word end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
doppelserver-1.0.0 | lib/doppelserver/routes/helpers/pluralize_helper.rb |