@@ -13,18 +13,18 @@ class Name < String
1313 def initialize ( klass , namespace = nil , name = nil )
1414 name ||= klass . name
1515 super ( name )
16- @unnamespaced = self . sub ( /^#{ namespace . name } ::/ , '' ) if namespace
1716
18- @klass = klass
19- @singular = _singularize ( self ) . freeze
20- @plural = ActiveSupport ::Inflector . pluralize ( @singular ) . freeze
21- @element = ActiveSupport ::Inflector . underscore ( ActiveSupport ::Inflector . demodulize ( self ) ) . freeze
22- @human = ActiveSupport ::Inflector . humanize ( @element ) . freeze
23- @collection = ActiveSupport ::Inflector . tableize ( self ) . freeze
17+ @unnamespaced = self . sub ( /^#{ namespace . name } ::/ , '' ) if namespace
18+ @klass = klass
19+ @singular = _singularize ( self ) . freeze
20+ @plural = ActiveSupport ::Inflector . pluralize ( @singular ) . freeze
21+ @element = ActiveSupport ::Inflector . underscore ( ActiveSupport ::Inflector . demodulize ( self ) ) . freeze
22+ @human = ActiveSupport ::Inflector . humanize ( @element ) . freeze
23+ @collection = ActiveSupport ::Inflector . tableize ( self ) . freeze
2424 @partial_path = "#{ @collection } /#{ @element } " . freeze
25- @param_key = ( namespace ? _singularize ( @unnamespaced ) : @singular ) . freeze
26- @route_key = ( namespace ? ActiveSupport ::Inflector . pluralize ( @param_key ) : @plural ) . freeze
27- @i18n_key = self . underscore . to_sym
25+ @param_key = ( namespace ? _singularize ( @unnamespaced ) : @singular ) . freeze
26+ @route_key = ( namespace ? ActiveSupport ::Inflector . pluralize ( @param_key ) : @plural ) . freeze
27+ @i18n_key = self . underscore . to_sym
2828 end
2929
3030 # Transform the model name into a more humane format, using I18n. By default,
@@ -79,7 +79,9 @@ module Naming
7979 # used to retrieve all kinds of naming-related information.
8080 def model_name
8181 @_model_name ||= begin
82- namespace = self . parents . detect { |n | n . respond_to? ( :_railtie ) }
82+ namespace = self . parents . detect do |n |
83+ n . respond_to? ( :use_relative_model_naming? ) && n . use_relative_model_naming?
84+ end
8385 ActiveModel ::Name . new ( self , namespace )
8486 end
8587 end
0 commit comments