Froze rails gems
[depot.git] / vendor / rails / activesupport / lib / active_support / core_ext / module / model_naming.rb
1 module ActiveSupport
2 class ModelName < String
3 attr_reader :singular, :plural, :cache_key, :partial_path
4
5 def initialize(name)
6 super
7 @singular = underscore.tr('/', '_').freeze
8 @plural = @singular.pluralize.freeze
9 @cache_key = tableize.freeze
10 @partial_path = "#{@cache_key}/#{demodulize.underscore}".freeze
11 end
12 end
13
14 module CoreExtensions
15 module Module
16 # Returns an ActiveSupport::ModelName object for module. It can be
17 # used to retrieve all kinds of naming-related information.
18 def model_name
19 @model_name ||= ModelName.new(name)
20 end
21 end
22 end
23 end