blob: 004b96a3c1ed24232f71b328a870dd019a6261b3 (
plain) (
tree)
|
|
module ActiveSupport
class ModelName < String
attr_reader :singular, :plural, :cache_key, :partial_path
def initialize(name)
super
@singular = underscore.tr('/', '_').freeze
@plural = @singular.pluralize.freeze
@cache_key = tableize.freeze
@partial_path = "#{@cache_key}/#{demodulize.underscore}".freeze
end
end
end
class Module
# Returns an ActiveSupport::ModelName object for module. It can be
# used to retrieve all kinds of naming-related information.
def model_name
@model_name ||= ActiveSupport::ModelName.new(name)
end
end
|