public
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/rails/rails.git
Move Class::ModelName to Active Support module core_ext
jeremy (author)
Fri Jun 06 03:38:05 -0700 2008
commit  566d717d783f56563cd602198be2177c972c9a81
tree    ff384a6a8c8c83054ff9db6335e6a28d6433aafe
parent  c1a98209da7422965f5dd4f475603b8a3cc887e4
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
...
59
60
61
62
 
63
64
 
65
66
67
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
...
43
44
45
 
46
47
 
48
49
50
51
0
@@ -1,19 +1,3 @@
0
-class Class
0
-  def model_name
0
-    @model_name ||= ModelName.new(name)
0
-  end
0
-
0
-  class ModelName
0
-    attr_reader :singular, :plural, :path
0
-
0
-    def initialize(name)
0
-      @singular = name.underscore.tr('/', '_').freeze
0
-      @plural = @singular.pluralize.freeze
0
-      @path = "#{name.tableize}/#{name.demodulize.underscore}".freeze
0
-    end
0
-  end
0
-end
0
-
0
 module ActionController  
0
   # The record identifier encapsulates a number of naming conventions for dealing with records, like Active Records or 
0
   # Active Resources or pretty much any other model type that has an id. These patterns are then used to try elevate
0
@@ -59,9 +43,9 @@ module ActionController
0
       name = model_name_from_record_or_class(record_or_class)
0
 
0
       if controller_path && controller_path.include?("/")
0
-        "#{File.dirname(controller_path)}/#{name.path}"
0
+        "#{File.dirname(controller_path)}/#{name.partial_path}"
0
       else
0
-        name.path
0
+        name.partial_path
0
       end
0
     end
0
 
...
6
7
8
 
 
 
 
 
...
6
7
8
9
10
11
12
13
0
@@ -6,3 +6,8 @@ require 'active_support/core_ext/module/delegation'
0
 require 'active_support/core_ext/module/introspection'
0
 require 'active_support/core_ext/module/loading'
0
 require 'active_support/core_ext/module/aliasing'
0
+require 'active_support/core_ext/module/model_naming'
0
+
0
+class Module
0
+  include ActiveSupport::CoreExt::Module::ModelNaming
0
+end

Comments