simplemapper 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +16 -0
- data/README +0 -0
- data/Rakefile +78 -0
- data/doc/classes/Array.html +139 -0
- data/doc/classes/Array.src/M000001.html +34 -0
- data/doc/classes/Callbacks.html +161 -0
- data/doc/classes/Callbacks.src/M000037.html +18 -0
- data/doc/classes/Callbacks.src/M000038.html +18 -0
- data/doc/classes/Callbacks.src/M000039.html +19 -0
- data/doc/classes/Enumerable.html +131 -0
- data/doc/classes/Enumerable.src/M000040.html +21 -0
- data/doc/classes/Hash.html +154 -0
- data/doc/classes/Hash.src/M000002.html +18 -0
- data/doc/classes/Hash.src/M000003.html +34 -0
- data/doc/classes/Inflector/Inflections.html +323 -0
- data/doc/classes/Inflector/Inflections.src/M000031.html +18 -0
- data/doc/classes/Inflector/Inflections.src/M000032.html +18 -0
- data/doc/classes/Inflector/Inflections.src/M000033.html +18 -0
- data/doc/classes/Inflector/Inflections.src/M000034.html +19 -0
- data/doc/classes/Inflector/Inflections.src/M000035.html +18 -0
- data/doc/classes/Inflector/Inflections.src/M000036.html +23 -0
- data/doc/classes/Inflector.html +516 -0
- data/doc/classes/Inflector.src/M000017.html +22 -0
- data/doc/classes/Inflector.src/M000018.html +25 -0
- data/doc/classes/Inflector.src/M000019.html +25 -0
- data/doc/classes/Inflector.src/M000020.html +22 -0
- data/doc/classes/Inflector.src/M000021.html +18 -0
- data/doc/classes/Inflector.src/M000022.html +22 -0
- data/doc/classes/Inflector.src/M000023.html +18 -0
- data/doc/classes/Inflector.src/M000024.html +18 -0
- data/doc/classes/Inflector.src/M000025.html +18 -0
- data/doc/classes/Inflector.src/M000026.html +18 -0
- data/doc/classes/Inflector.src/M000027.html +19 -0
- data/doc/classes/Inflector.src/M000028.html +18 -0
- data/doc/classes/Inflector.src/M000029.html +22 -0
- data/doc/classes/Inflector.src/M000030.html +27 -0
- data/doc/classes/Merb/Request.html +139 -0
- data/doc/classes/Merb/Request.src/M000041.html +22 -0
- data/doc/classes/Merb.html +111 -0
- data/doc/classes/OAuth/RequestProxy/Base.html +139 -0
- data/doc/classes/OAuth/RequestProxy/Base.src/M000012.html +18 -0
- data/doc/classes/OAuth/RequestProxy.html +111 -0
- data/doc/classes/OAuth/Signature/Base.html +139 -0
- data/doc/classes/OAuth/Signature/Base.src/M000011.html +25 -0
- data/doc/classes/OAuth/Signature.html +111 -0
- data/doc/classes/OAuth.html +112 -0
- data/doc/classes/OAuthController.html +243 -0
- data/doc/classes/OAuthController.src/M000005.html +22 -0
- data/doc/classes/OAuthController.src/M000006.html +18 -0
- data/doc/classes/OAuthController.src/M000007.html +18 -0
- data/doc/classes/OAuthController.src/M000008.html +25 -0
- data/doc/classes/OAuthController.src/M000009.html +19 -0
- data/doc/classes/Object.html +142 -0
- data/doc/classes/Object.src/M000010.html +19 -0
- data/doc/classes/Proc.html +143 -0
- data/doc/classes/Proc.src/M000004.html +18 -0
- data/doc/classes/Serialize.html +189 -0
- data/doc/classes/Serialize.src/M000013.html +21 -0
- data/doc/classes/Serialize.src/M000014.html +39 -0
- data/doc/classes/Serialize.src/M000015.html +16 -0
- data/doc/classes/Serialize.src/M000016.html +46 -0
- data/doc/classes/SimpleMapper/Base.html +528 -0
- data/doc/classes/SimpleMapper/Base.src/M000064.html +16 -0
- data/doc/classes/SimpleMapper/Base.src/M000065.html +16 -0
- data/doc/classes/SimpleMapper/Base.src/M000066.html +22 -0
- data/doc/classes/SimpleMapper/Base.src/M000067.html +21 -0
- data/doc/classes/SimpleMapper/Base.src/M000068.html +26 -0
- data/doc/classes/SimpleMapper/Base.src/M000069.html +18 -0
- data/doc/classes/SimpleMapper/Base.src/M000070.html +18 -0
- data/doc/classes/SimpleMapper/Base.src/M000071.html +18 -0
- data/doc/classes/SimpleMapper/Base.src/M000072.html +19 -0
- data/doc/classes/SimpleMapper/Base.src/M000073.html +23 -0
- data/doc/classes/SimpleMapper/Base.src/M000074.html +18 -0
- data/doc/classes/SimpleMapper/Base.src/M000075.html +20 -0
- data/doc/classes/SimpleMapper/Base.src/M000076.html +18 -0
- data/doc/classes/SimpleMapper/Base.src/M000077.html +18 -0
- data/doc/classes/SimpleMapper/Base.src/M000078.html +19 -0
- data/doc/classes/SimpleMapper/Base.src/M000079.html +18 -0
- data/doc/classes/SimpleMapper/Base.src/M000080.html +18 -0
- data/doc/classes/SimpleMapper/Base.src/M000081.html +19 -0
- data/doc/classes/SimpleMapper/Base.src/M000082.html +20 -0
- data/doc/classes/SimpleMapper/Base.src/M000083.html +24 -0
- data/doc/classes/SimpleMapper/Base.src/M000084.html +18 -0
- data/doc/classes/SimpleMapper/HttpAdapter.html +280 -0
- data/doc/classes/SimpleMapper/HttpAdapter.src/M000056.html +18 -0
- data/doc/classes/SimpleMapper/HttpAdapter.src/M000057.html +18 -0
- data/doc/classes/SimpleMapper/HttpAdapter.src/M000058.html +19 -0
- data/doc/classes/SimpleMapper/HttpAdapter.src/M000060.html +18 -0
- data/doc/classes/SimpleMapper/HttpAdapter.src/M000061.html +18 -0
- data/doc/classes/SimpleMapper/HttpAdapter.src/M000062.html +18 -0
- data/doc/classes/SimpleMapper/HttpAdapter.src/M000063.html +18 -0
- data/doc/classes/SimpleMapper/HttpOAuthExtension.html +188 -0
- data/doc/classes/SimpleMapper/HttpOAuthExtension.src/M000048.html +49 -0
- data/doc/classes/SimpleMapper/HttpOAuthExtension.src/M000049.html +23 -0
- data/doc/classes/SimpleMapper/HttpOAuthExtension.src/M000050.html +18 -0
- data/doc/classes/SimpleMapper/HttpOAuthExtension.src/M000051.html +24 -0
- data/doc/classes/SimpleMapper/SimpleModel/ClassMethods.html +146 -0
- data/doc/classes/SimpleMapper/SimpleModel/ClassMethods.src/M000046.html +19 -0
- data/doc/classes/SimpleMapper/SimpleModel/ClassMethods.src/M000047.html +19 -0
- data/doc/classes/SimpleMapper/SimpleModel.html +184 -0
- data/doc/classes/SimpleMapper/SimpleModel.src/M000042.html +18 -0
- data/doc/classes/SimpleMapper/SimpleModel.src/M000043.html +18 -0
- data/doc/classes/SimpleMapper/SimpleModel.src/M000044.html +18 -0
- data/doc/classes/SimpleMapper/SimpleModel.src/M000045.html +24 -0
- data/doc/classes/SimpleMapper/XmlFormat/ClassMethods.html +152 -0
- data/doc/classes/SimpleMapper/XmlFormat/ClassMethods.src/M000055.html +30 -0
- data/doc/classes/SimpleMapper/XmlFormat.html +169 -0
- data/doc/classes/SimpleMapper/XmlFormat.src/M000052.html +18 -0
- data/doc/classes/SimpleMapper/XmlFormat.src/M000053.html +18 -0
- data/doc/classes/SimpleMapper/XmlFormat.src/M000054.html +18 -0
- data/doc/classes/SimpleMapper.html +146 -0
- data/doc/classes/String.html +120 -0
- data/doc/created.rid +1 -0
- data/doc/files/lib/simple_mapper/adapters/http_adapter_rb.html +110 -0
- data/doc/files/lib/simple_mapper/base_rb.html +108 -0
- data/doc/files/lib/simple_mapper/default_plugins/callbacks_rb.html +101 -0
- data/doc/files/lib/simple_mapper/default_plugins/oauth_rb.html +116 -0
- data/doc/files/lib/simple_mapper/default_plugins/simple_model_rb.html +101 -0
- data/doc/files/lib/simple_mapper/formats/xml_format_rb.html +108 -0
- data/doc/files/lib/simple_mapper/support/bliss_serializer_rb.html +109 -0
- data/doc/files/lib/simple_mapper/support/core_ext_rb.html +108 -0
- data/doc/files/lib/simple_mapper/support/inflections_rb.html +101 -0
- data/doc/files/lib/simple_mapper/support/inflector_rb.html +108 -0
- data/doc/files/lib/simple_mapper/support_rb.html +109 -0
- data/doc/files/lib/simple_mapper_rb.html +137 -0
- data/doc/fr_class_index.html +52 -0
- data/doc/fr_file_index.html +38 -0
- data/doc/fr_method_index.html +110 -0
- data/doc/index.html +24 -0
- data/doc/rdoc-style.css +208 -0
- data/lib/simple_mapper/adapters/http_adapter.rb +64 -0
- data/lib/simple_mapper/base.rb +138 -0
- data/lib/simple_mapper/default_plugins/callbacks.rb +12 -0
- data/lib/simple_mapper/default_plugins/oauth.rb +167 -0
- data/lib/simple_mapper/default_plugins/simple_model.rb +36 -0
- data/lib/simple_mapper/formats/xml_format.rb +48 -0
- data/lib/simple_mapper/support/bliss_serializer.rb +168 -0
- data/lib/simple_mapper/support/core_ext.rb +73 -0
- data/lib/simple_mapper/support/inflections.rb +112 -0
- data/lib/simple_mapper/support/inflector.rb +275 -0
- data/lib/simple_mapper/support.rb +2 -0
- data/lib/simple_mapper.rb +16 -0
- metadata +236 -0
@@ -0,0 +1,18 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html>
|
7
|
+
<head>
|
8
|
+
<title>new (Inflector::Inflections)</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
+
</head>
|
12
|
+
<body class="standalone-code">
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/simple_mapper/support/inflector.rb, line 27</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>
|
15
|
+
<span class="ruby-ivar">@plurals</span>, <span class="ruby-ivar">@singulars</span>, <span class="ruby-ivar">@uncountables</span> = [], [], []
|
16
|
+
<span class="ruby-keyword kw">end</span></pre>
|
17
|
+
</body>
|
18
|
+
</html>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html>
|
7
|
+
<head>
|
8
|
+
<title>plural (Inflector::Inflections)</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
+
</head>
|
12
|
+
<body class="standalone-code">
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/simple_mapper/support/inflector.rb, line 33</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">plural</span>(<span class="ruby-identifier">rule</span>, <span class="ruby-identifier">replacement</span>)
|
15
|
+
<span class="ruby-ivar">@plurals</span>.<span class="ruby-identifier">insert</span>(<span class="ruby-value">0</span>, [<span class="ruby-identifier">rule</span>, <span class="ruby-identifier">replacement</span>])
|
16
|
+
<span class="ruby-keyword kw">end</span></pre>
|
17
|
+
</body>
|
18
|
+
</html>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html>
|
7
|
+
<head>
|
8
|
+
<title>singular (Inflector::Inflections)</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
+
</head>
|
12
|
+
<body class="standalone-code">
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/simple_mapper/support/inflector.rb, line 39</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">singular</span>(<span class="ruby-identifier">rule</span>, <span class="ruby-identifier">replacement</span>)
|
15
|
+
<span class="ruby-ivar">@singulars</span>.<span class="ruby-identifier">insert</span>(<span class="ruby-value">0</span>, [<span class="ruby-identifier">rule</span>, <span class="ruby-identifier">replacement</span>])
|
16
|
+
<span class="ruby-keyword kw">end</span></pre>
|
17
|
+
</body>
|
18
|
+
</html>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html>
|
7
|
+
<head>
|
8
|
+
<title>irregular (Inflector::Inflections)</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
+
</head>
|
12
|
+
<body class="standalone-code">
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/simple_mapper/support/inflector.rb, line 49</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">irregular</span>(<span class="ruby-identifier">singular</span>, <span class="ruby-identifier">plural</span>)
|
15
|
+
<span class="ruby-identifier">plural</span>(<span class="ruby-constant">Regexp</span>.<span class="ruby-identifier">new</span>(<span class="ruby-node">"(#{singular[0,1]})#{singular[1..-1]}$"</span>, <span class="ruby-value str">"i"</span>), <span class="ruby-value str">'\1'</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">plural</span>[<span class="ruby-value">1</span><span class="ruby-operator">..</span><span class="ruby-value">-1</span>])
|
16
|
+
<span class="ruby-identifier">singular</span>(<span class="ruby-constant">Regexp</span>.<span class="ruby-identifier">new</span>(<span class="ruby-node">"(#{plural[0,1]})#{plural[1..-1]}$"</span>, <span class="ruby-value str">"i"</span>), <span class="ruby-value str">'\1'</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">singular</span>[<span class="ruby-value">1</span><span class="ruby-operator">..</span><span class="ruby-value">-1</span>])
|
17
|
+
<span class="ruby-keyword kw">end</span></pre>
|
18
|
+
</body>
|
19
|
+
</html>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html>
|
7
|
+
<head>
|
8
|
+
<title>uncountable (Inflector::Inflections)</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
+
</head>
|
12
|
+
<body class="standalone-code">
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/simple_mapper/support/inflector.rb, line 60</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">uncountable</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">words</span>)
|
15
|
+
(<span class="ruby-ivar">@uncountables</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">words</span>).<span class="ruby-identifier">flatten!</span>
|
16
|
+
<span class="ruby-keyword kw">end</span></pre>
|
17
|
+
</body>
|
18
|
+
</html>
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html>
|
7
|
+
<head>
|
8
|
+
<title>clear (Inflector::Inflections)</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
+
</head>
|
12
|
+
<body class="standalone-code">
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/simple_mapper/support/inflector.rb, line 70</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">clear</span>(<span class="ruby-identifier">scope</span> = <span class="ruby-identifier">:all</span>)
|
15
|
+
<span class="ruby-keyword kw">case</span> <span class="ruby-identifier">scope</span>
|
16
|
+
<span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:all</span>
|
17
|
+
<span class="ruby-ivar">@plurals</span>, <span class="ruby-ivar">@singulars</span>, <span class="ruby-ivar">@uncountables</span> = [], [], []
|
18
|
+
<span class="ruby-keyword kw">else</span>
|
19
|
+
<span class="ruby-identifier">instance_variable_set</span> <span class="ruby-node">"@#{scope}"</span>, []
|
20
|
+
<span class="ruby-keyword kw">end</span>
|
21
|
+
<span class="ruby-keyword kw">end</span></pre>
|
22
|
+
</body>
|
23
|
+
</html>
|
@@ -0,0 +1,516 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
+
<head>
|
8
|
+
<title>Module: Inflector</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
+
<link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
|
12
|
+
<script type="text/javascript">
|
13
|
+
// <![CDATA[
|
14
|
+
|
15
|
+
function popupCode( url ) {
|
16
|
+
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
+
}
|
18
|
+
|
19
|
+
function toggleCode( id ) {
|
20
|
+
if ( document.getElementById )
|
21
|
+
elem = document.getElementById( id );
|
22
|
+
else if ( document.all )
|
23
|
+
elem = eval( "document.all." + id );
|
24
|
+
else
|
25
|
+
return false;
|
26
|
+
|
27
|
+
elemStyle = elem.style;
|
28
|
+
|
29
|
+
if ( elemStyle.display != "block" ) {
|
30
|
+
elemStyle.display = "block"
|
31
|
+
} else {
|
32
|
+
elemStyle.display = "none"
|
33
|
+
}
|
34
|
+
|
35
|
+
return true;
|
36
|
+
}
|
37
|
+
|
38
|
+
// Make codeblocks hidden by default
|
39
|
+
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
+
|
41
|
+
// ]]>
|
42
|
+
</script>
|
43
|
+
|
44
|
+
</head>
|
45
|
+
<body>
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
<div id="classHeader">
|
50
|
+
<table class="header-table">
|
51
|
+
<tr class="top-aligned-row">
|
52
|
+
<td><strong>Module</strong></td>
|
53
|
+
<td class="class-name-in-header">Inflector</td>
|
54
|
+
</tr>
|
55
|
+
<tr class="top-aligned-row">
|
56
|
+
<td><strong>In:</strong></td>
|
57
|
+
<td>
|
58
|
+
<a href="../files/lib/simple_mapper/support/inflector_rb.html">
|
59
|
+
lib/simple_mapper/support/inflector.rb
|
60
|
+
</a>
|
61
|
+
<br />
|
62
|
+
</td>
|
63
|
+
</tr>
|
64
|
+
|
65
|
+
</table>
|
66
|
+
</div>
|
67
|
+
<!-- banner header -->
|
68
|
+
|
69
|
+
<div id="bodyContent">
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
<div id="contextContent">
|
74
|
+
|
75
|
+
<div id="description">
|
76
|
+
<p>
|
77
|
+
The <a href="Inflector.html">Inflector</a> transforms words from singular
|
78
|
+
to plural, class names to table names, modularized class names to ones
|
79
|
+
without, and class names to foreign keys. The default <a
|
80
|
+
href="Inflector.html#M000017">inflections</a> for pluralization,
|
81
|
+
singularization, and uncountable words are kept in inflections.rb.
|
82
|
+
</p>
|
83
|
+
|
84
|
+
</div>
|
85
|
+
|
86
|
+
|
87
|
+
</div>
|
88
|
+
|
89
|
+
<div id="method-list">
|
90
|
+
<h3 class="section-bar">Methods</h3>
|
91
|
+
|
92
|
+
<div class="name-list">
|
93
|
+
<a href="#M000020">camelize</a>
|
94
|
+
<a href="#M000027">classify</a>
|
95
|
+
<a href="#M000029">constantize</a>
|
96
|
+
<a href="#M000023">dasherize</a>
|
97
|
+
<a href="#M000025">demodulize</a>
|
98
|
+
<a href="#M000028">foreign_key</a>
|
99
|
+
<a href="#M000024">humanize</a>
|
100
|
+
<a href="#M000017">inflections</a>
|
101
|
+
<a href="#M000030">ordinalize</a>
|
102
|
+
<a href="#M000018">pluralize</a>
|
103
|
+
<a href="#M000019">singularize</a>
|
104
|
+
<a href="#M000026">tableize</a>
|
105
|
+
<a href="#M000021">titleize</a>
|
106
|
+
<a href="#M000022">underscore</a>
|
107
|
+
</div>
|
108
|
+
</div>
|
109
|
+
|
110
|
+
</div>
|
111
|
+
|
112
|
+
|
113
|
+
<!-- if includes -->
|
114
|
+
|
115
|
+
<div id="section">
|
116
|
+
|
117
|
+
<div id="class-list">
|
118
|
+
<h3 class="section-bar">Classes and Modules</h3>
|
119
|
+
|
120
|
+
Class <a href="Inflector/Inflections.html" class="link">Inflector::Inflections</a><br />
|
121
|
+
|
122
|
+
</div>
|
123
|
+
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
|
130
|
+
<!-- if method_list -->
|
131
|
+
<div id="methods">
|
132
|
+
<h3 class="section-bar">Public Instance methods</h3>
|
133
|
+
|
134
|
+
<div id="method-M000020" class="method-detail">
|
135
|
+
<a name="M000020"></a>
|
136
|
+
|
137
|
+
<div class="method-heading">
|
138
|
+
<a href="Inflector.src/M000020.html" target="Code" class="method-signature"
|
139
|
+
onclick="popupCode('Inflector.src/M000020.html');return false;">
|
140
|
+
<span class="method-name">camelize</span><span class="method-args">(lower_case_and_underscored_word, first_letter_in_uppercase = true)</span>
|
141
|
+
</a>
|
142
|
+
</div>
|
143
|
+
|
144
|
+
<div class="method-description">
|
145
|
+
<p>
|
146
|
+
By default, <a href="Inflector.html#M000020">camelize</a> converts strings
|
147
|
+
to UpperCamelCase. If the argument to <a
|
148
|
+
href="Inflector.html#M000020">camelize</a> is set to ":lower"
|
149
|
+
then <a href="Inflector.html#M000020">camelize</a> produces lowerCamelCase.
|
150
|
+
</p>
|
151
|
+
<p>
|
152
|
+
<a href="Inflector.html#M000020">camelize</a> will also convert
|
153
|
+
’/’ to ’::’ which is useful for converting paths to
|
154
|
+
namespaces
|
155
|
+
</p>
|
156
|
+
<p>
|
157
|
+
Examples
|
158
|
+
</p>
|
159
|
+
<pre>
|
160
|
+
"active_record".camelize #=> "ActiveRecord"
|
161
|
+
"active_record".camelize(:lower) #=> "activeRecord"
|
162
|
+
"active_record/errors".camelize #=> "ActiveRecord::Errors"
|
163
|
+
"active_record/errors".camelize(:lower) #=> "activeRecord::Errors"
|
164
|
+
</pre>
|
165
|
+
</div>
|
166
|
+
</div>
|
167
|
+
|
168
|
+
<div id="method-M000027" class="method-detail">
|
169
|
+
<a name="M000027"></a>
|
170
|
+
|
171
|
+
<div class="method-heading">
|
172
|
+
<a href="Inflector.src/M000027.html" target="Code" class="method-signature"
|
173
|
+
onclick="popupCode('Inflector.src/M000027.html');return false;">
|
174
|
+
<span class="method-name">classify</span><span class="method-args">(table_name)</span>
|
175
|
+
</a>
|
176
|
+
</div>
|
177
|
+
|
178
|
+
<div class="method-description">
|
179
|
+
<p>
|
180
|
+
Create a class name from a table name like Rails does for table names to
|
181
|
+
models. Note that this returns a string and not a Class. (To convert to an
|
182
|
+
actual class follow <a href="Inflector.html#M000027">classify</a> with <a
|
183
|
+
href="Inflector.html#M000029">constantize</a>.)
|
184
|
+
</p>
|
185
|
+
<p>
|
186
|
+
Examples
|
187
|
+
</p>
|
188
|
+
<pre>
|
189
|
+
"egg_and_hams".classify #=> "EggAndHam"
|
190
|
+
"post".classify #=> "Post"
|
191
|
+
</pre>
|
192
|
+
</div>
|
193
|
+
</div>
|
194
|
+
|
195
|
+
<div id="method-M000029" class="method-detail">
|
196
|
+
<a name="M000029"></a>
|
197
|
+
|
198
|
+
<div class="method-heading">
|
199
|
+
<a href="Inflector.src/M000029.html" target="Code" class="method-signature"
|
200
|
+
onclick="popupCode('Inflector.src/M000029.html');return false;">
|
201
|
+
<span class="method-name">constantize</span><span class="method-args">(camel_cased_word)</span>
|
202
|
+
</a>
|
203
|
+
</div>
|
204
|
+
|
205
|
+
<div class="method-description">
|
206
|
+
<p>
|
207
|
+
Constantize tries to find a declared constant with the name specified in
|
208
|
+
the string. It raises a NameError when the name is not in CamelCase or is
|
209
|
+
not initialized.
|
210
|
+
</p>
|
211
|
+
<p>
|
212
|
+
Examples
|
213
|
+
</p>
|
214
|
+
<pre>
|
215
|
+
"Module".constantize #=> Module
|
216
|
+
"Class".constantize #=> Class
|
217
|
+
</pre>
|
218
|
+
</div>
|
219
|
+
</div>
|
220
|
+
|
221
|
+
<div id="method-M000023" class="method-detail">
|
222
|
+
<a name="M000023"></a>
|
223
|
+
|
224
|
+
<div class="method-heading">
|
225
|
+
<a href="Inflector.src/M000023.html" target="Code" class="method-signature"
|
226
|
+
onclick="popupCode('Inflector.src/M000023.html');return false;">
|
227
|
+
<span class="method-name">dasherize</span><span class="method-args">(underscored_word)</span>
|
228
|
+
</a>
|
229
|
+
</div>
|
230
|
+
|
231
|
+
<div class="method-description">
|
232
|
+
<p>
|
233
|
+
Replaces underscores with dashes in the string.
|
234
|
+
</p>
|
235
|
+
<p>
|
236
|
+
Example
|
237
|
+
</p>
|
238
|
+
<pre>
|
239
|
+
"puni_puni" #=> "puni-puni"
|
240
|
+
</pre>
|
241
|
+
</div>
|
242
|
+
</div>
|
243
|
+
|
244
|
+
<div id="method-M000025" class="method-detail">
|
245
|
+
<a name="M000025"></a>
|
246
|
+
|
247
|
+
<div class="method-heading">
|
248
|
+
<a href="Inflector.src/M000025.html" target="Code" class="method-signature"
|
249
|
+
onclick="popupCode('Inflector.src/M000025.html');return false;">
|
250
|
+
<span class="method-name">demodulize</span><span class="method-args">(class_name_in_module)</span>
|
251
|
+
</a>
|
252
|
+
</div>
|
253
|
+
|
254
|
+
<div class="method-description">
|
255
|
+
<p>
|
256
|
+
Removes the module part from the expression in the string
|
257
|
+
</p>
|
258
|
+
<p>
|
259
|
+
Examples
|
260
|
+
</p>
|
261
|
+
<pre>
|
262
|
+
"ActiveRecord::CoreExtensions::String::Inflections".demodulize #=> "Inflections"
|
263
|
+
"Inflections".demodulize #=> "Inflections"
|
264
|
+
</pre>
|
265
|
+
</div>
|
266
|
+
</div>
|
267
|
+
|
268
|
+
<div id="method-M000028" class="method-detail">
|
269
|
+
<a name="M000028"></a>
|
270
|
+
|
271
|
+
<div class="method-heading">
|
272
|
+
<a href="Inflector.src/M000028.html" target="Code" class="method-signature"
|
273
|
+
onclick="popupCode('Inflector.src/M000028.html');return false;">
|
274
|
+
<span class="method-name">foreign_key</span><span class="method-args">(class_name, separate_class_name_and_id_with_underscore = true)</span>
|
275
|
+
</a>
|
276
|
+
</div>
|
277
|
+
|
278
|
+
<div class="method-description">
|
279
|
+
<p>
|
280
|
+
Creates a foreign key name from a class name.
|
281
|
+
<tt>separate_class_name_and_id_with_underscore</tt> sets whether the method
|
282
|
+
should put ‘_’ between the name and ‘id’.
|
283
|
+
</p>
|
284
|
+
<p>
|
285
|
+
Examples
|
286
|
+
</p>
|
287
|
+
<pre>
|
288
|
+
"Message".foreign_key #=> "message_id"
|
289
|
+
"Message".foreign_key(false) #=> "messageid"
|
290
|
+
"Admin::Post".foreign_key #=> "post_id"
|
291
|
+
</pre>
|
292
|
+
</div>
|
293
|
+
</div>
|
294
|
+
|
295
|
+
<div id="method-M000024" class="method-detail">
|
296
|
+
<a name="M000024"></a>
|
297
|
+
|
298
|
+
<div class="method-heading">
|
299
|
+
<a href="Inflector.src/M000024.html" target="Code" class="method-signature"
|
300
|
+
onclick="popupCode('Inflector.src/M000024.html');return false;">
|
301
|
+
<span class="method-name">humanize</span><span class="method-args">(lower_case_and_underscored_word)</span>
|
302
|
+
</a>
|
303
|
+
</div>
|
304
|
+
|
305
|
+
<div class="method-description">
|
306
|
+
<p>
|
307
|
+
Capitalizes the first word and turns underscores into spaces and strips
|
308
|
+
_id. Like <a href="Inflector.html#M000021">titleize</a>, this is meant for
|
309
|
+
creating pretty output.
|
310
|
+
</p>
|
311
|
+
<p>
|
312
|
+
Examples
|
313
|
+
</p>
|
314
|
+
<pre>
|
315
|
+
"employee_salary" #=> "Employee salary"
|
316
|
+
"author_id" #=> "Author"
|
317
|
+
</pre>
|
318
|
+
</div>
|
319
|
+
</div>
|
320
|
+
|
321
|
+
<div id="method-M000017" class="method-detail">
|
322
|
+
<a name="M000017"></a>
|
323
|
+
|
324
|
+
<div class="method-heading">
|
325
|
+
<a href="Inflector.src/M000017.html" target="Code" class="method-signature"
|
326
|
+
onclick="popupCode('Inflector.src/M000017.html');return false;">
|
327
|
+
<span class="method-name">inflections</span><span class="method-args">() {|Inflections.instance| ...}</span>
|
328
|
+
</a>
|
329
|
+
</div>
|
330
|
+
|
331
|
+
<div class="method-description">
|
332
|
+
</div>
|
333
|
+
</div>
|
334
|
+
|
335
|
+
<div id="method-M000030" class="method-detail">
|
336
|
+
<a name="M000030"></a>
|
337
|
+
|
338
|
+
<div class="method-heading">
|
339
|
+
<a href="Inflector.src/M000030.html" target="Code" class="method-signature"
|
340
|
+
onclick="popupCode('Inflector.src/M000030.html');return false;">
|
341
|
+
<span class="method-name">ordinalize</span><span class="method-args">(number)</span>
|
342
|
+
</a>
|
343
|
+
</div>
|
344
|
+
|
345
|
+
<div class="method-description">
|
346
|
+
<p>
|
347
|
+
Ordinalize turns a number into an ordinal string used to denote the
|
348
|
+
position in an ordered sequence such as 1st, 2nd, 3rd, 4th.
|
349
|
+
</p>
|
350
|
+
<p>
|
351
|
+
Examples
|
352
|
+
</p>
|
353
|
+
<pre>
|
354
|
+
ordinalize(1) # => "1st"
|
355
|
+
ordinalize(2) # => "2nd"
|
356
|
+
ordinalize(1002) # => "1002nd"
|
357
|
+
ordinalize(1003) # => "1003rd"
|
358
|
+
</pre>
|
359
|
+
</div>
|
360
|
+
</div>
|
361
|
+
|
362
|
+
<div id="method-M000018" class="method-detail">
|
363
|
+
<a name="M000018"></a>
|
364
|
+
|
365
|
+
<div class="method-heading">
|
366
|
+
<a href="Inflector.src/M000018.html" target="Code" class="method-signature"
|
367
|
+
onclick="popupCode('Inflector.src/M000018.html');return false;">
|
368
|
+
<span class="method-name">pluralize</span><span class="method-args">(word)</span>
|
369
|
+
</a>
|
370
|
+
</div>
|
371
|
+
|
372
|
+
<div class="method-description">
|
373
|
+
<p>
|
374
|
+
Returns the plural form of the word in the string.
|
375
|
+
</p>
|
376
|
+
<p>
|
377
|
+
Examples
|
378
|
+
</p>
|
379
|
+
<pre>
|
380
|
+
"post".pluralize #=> "posts"
|
381
|
+
"octopus".pluralize #=> "octopi"
|
382
|
+
"sheep".pluralize #=> "sheep"
|
383
|
+
"words".pluralize #=> "words"
|
384
|
+
"the blue mailman".pluralize #=> "the blue mailmen"
|
385
|
+
"CamelOctopus".pluralize #=> "CamelOctopi"
|
386
|
+
</pre>
|
387
|
+
</div>
|
388
|
+
</div>
|
389
|
+
|
390
|
+
<div id="method-M000019" class="method-detail">
|
391
|
+
<a name="M000019"></a>
|
392
|
+
|
393
|
+
<div class="method-heading">
|
394
|
+
<a href="Inflector.src/M000019.html" target="Code" class="method-signature"
|
395
|
+
onclick="popupCode('Inflector.src/M000019.html');return false;">
|
396
|
+
<span class="method-name">singularize</span><span class="method-args">(word)</span>
|
397
|
+
</a>
|
398
|
+
</div>
|
399
|
+
|
400
|
+
<div class="method-description">
|
401
|
+
<p>
|
402
|
+
The reverse of <a href="Inflector.html#M000018">pluralize</a>, returns the
|
403
|
+
singular form of a word in a string.
|
404
|
+
</p>
|
405
|
+
<p>
|
406
|
+
Examples
|
407
|
+
</p>
|
408
|
+
<pre>
|
409
|
+
"posts".singularize #=> "post"
|
410
|
+
"octopi".singularize #=> "octopus"
|
411
|
+
"sheep".singluarize #=> "sheep"
|
412
|
+
"word".singluarize #=> "word"
|
413
|
+
"the blue mailmen".singularize #=> "the blue mailman"
|
414
|
+
"CamelOctopi".singularize #=> "CamelOctopus"
|
415
|
+
</pre>
|
416
|
+
</div>
|
417
|
+
</div>
|
418
|
+
|
419
|
+
<div id="method-M000026" class="method-detail">
|
420
|
+
<a name="M000026"></a>
|
421
|
+
|
422
|
+
<div class="method-heading">
|
423
|
+
<a href="Inflector.src/M000026.html" target="Code" class="method-signature"
|
424
|
+
onclick="popupCode('Inflector.src/M000026.html');return false;">
|
425
|
+
<span class="method-name">tableize</span><span class="method-args">(class_name)</span>
|
426
|
+
</a>
|
427
|
+
</div>
|
428
|
+
|
429
|
+
<div class="method-description">
|
430
|
+
<p>
|
431
|
+
Create the name of a table like Rails does for models to table names. This
|
432
|
+
method uses the <a href="Inflector.html#M000018">pluralize</a> method on
|
433
|
+
the last word in the string.
|
434
|
+
</p>
|
435
|
+
<p>
|
436
|
+
Examples
|
437
|
+
</p>
|
438
|
+
<pre>
|
439
|
+
"RawScaledScorer".tableize #=> "raw_scaled_scorers"
|
440
|
+
"egg_and_ham".tableize #=> "egg_and_hams"
|
441
|
+
"fancyCategory".tableize #=> "fancy_categories"
|
442
|
+
</pre>
|
443
|
+
</div>
|
444
|
+
</div>
|
445
|
+
|
446
|
+
<div id="method-M000021" class="method-detail">
|
447
|
+
<a name="M000021"></a>
|
448
|
+
|
449
|
+
<div class="method-heading">
|
450
|
+
<a href="Inflector.src/M000021.html" target="Code" class="method-signature"
|
451
|
+
onclick="popupCode('Inflector.src/M000021.html');return false;">
|
452
|
+
<span class="method-name">titleize</span><span class="method-args">(word)</span>
|
453
|
+
</a>
|
454
|
+
</div>
|
455
|
+
|
456
|
+
<div class="method-description">
|
457
|
+
<p>
|
458
|
+
Capitalizes all the words and replaces some characters in the string to
|
459
|
+
create a nicer looking title. Titleize is meant for creating pretty output.
|
460
|
+
It is not used in the Rails internals.
|
461
|
+
</p>
|
462
|
+
<p>
|
463
|
+
<a href="Inflector.html#M000021">titleize</a> is also aliased as as
|
464
|
+
titlecase
|
465
|
+
</p>
|
466
|
+
<p>
|
467
|
+
Examples
|
468
|
+
</p>
|
469
|
+
<pre>
|
470
|
+
"man from the boondocks".titleize #=> "Man From The Boondocks"
|
471
|
+
"x-men: the last stand".titleize #=> "X Men: The Last Stand"
|
472
|
+
</pre>
|
473
|
+
</div>
|
474
|
+
</div>
|
475
|
+
|
476
|
+
<div id="method-M000022" class="method-detail">
|
477
|
+
<a name="M000022"></a>
|
478
|
+
|
479
|
+
<div class="method-heading">
|
480
|
+
<a href="Inflector.src/M000022.html" target="Code" class="method-signature"
|
481
|
+
onclick="popupCode('Inflector.src/M000022.html');return false;">
|
482
|
+
<span class="method-name">underscore</span><span class="method-args">(camel_cased_word)</span>
|
483
|
+
</a>
|
484
|
+
</div>
|
485
|
+
|
486
|
+
<div class="method-description">
|
487
|
+
<p>
|
488
|
+
The reverse of <tt><a href="Inflector.html#M000020">camelize</a></tt>.
|
489
|
+
Makes an underscored form from the expression in the string.
|
490
|
+
</p>
|
491
|
+
<p>
|
492
|
+
Changes ’::’ to ’/’ to convert namespaces to paths.
|
493
|
+
</p>
|
494
|
+
<p>
|
495
|
+
Examples
|
496
|
+
</p>
|
497
|
+
<pre>
|
498
|
+
"ActiveRecord".underscore #=> "active_record"
|
499
|
+
"ActiveRecord::Errors".underscore #=> active_record/errors
|
500
|
+
</pre>
|
501
|
+
</div>
|
502
|
+
</div>
|
503
|
+
|
504
|
+
|
505
|
+
</div>
|
506
|
+
|
507
|
+
|
508
|
+
</div>
|
509
|
+
|
510
|
+
|
511
|
+
<div id="validator-badges">
|
512
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
513
|
+
</div>
|
514
|
+
|
515
|
+
</body>
|
516
|
+
</html>
|