2
class ModelName < String
3
attr_reader :singular, :plural, :element, :collection, :partial_path
4
alias_method :cache_key, :collection
8
@singular = ActiveSupport::Inflector.underscore(self).tr('/', '_').freeze
9
@plural = ActiveSupport::Inflector.pluralize(@singular).freeze
10
@element = ActiveSupport::Inflector.underscore(ActiveSupport::Inflector.demodulize(self)).freeze
11
@collection = ActiveSupport::Inflector.tableize(self).freeze
12
@partial_path = "#{@collection}/#{@element}".freeze
18
# Returns an ActiveSupport::ModelName object for module. It can be
19
# used to retrieve all kinds of naming-related information.
21
@model_name ||= ::ActiveSupport::ModelName.new(name)