magic_userstamp 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. data/README.rdoc +78 -8
  2. data/Rakefile +2 -1
  3. data/VERSION +1 -1
  4. data/init.rb +5 -7
  5. data/lib/magic_userstamp.rb +27 -0
  6. data/lib/{userstamp → magic_userstamp}/config.rb +11 -12
  7. data/lib/{userstamp → magic_userstamp}/controller.rb +2 -2
  8. data/lib/{userstamp → magic_userstamp}/event.rb +3 -3
  9. data/lib/{userstamp → magic_userstamp}/magic_columns.rb +3 -3
  10. data/lib/magic_userstamp/migration_helper.rb +17 -0
  11. data/lib/{userstamp → magic_userstamp}/stampable.rb +15 -15
  12. data/lib/{userstamp → magic_userstamp}/stamper.rb +5 -5
  13. data/magic_userstamp.gemspec +36 -29
  14. data/rdoc/classes/MagicUserstamp.html +233 -0
  15. data/rdoc/classes/MagicUserstamp/Config.html +408 -0
  16. data/rdoc/classes/MagicUserstamp/Config/Pattern.html +246 -0
  17. data/rdoc/classes/{Ddb → MagicUserstamp}/Controller.html +7 -7
  18. data/rdoc/classes/{Ddb/Controller/Userstamp → MagicUserstamp/Controller}/InstanceMethods.html +7 -7
  19. data/rdoc/classes/MagicUserstamp/Event.html +367 -0
  20. data/rdoc/classes/MagicUserstamp/MagicColumns.html +180 -0
  21. data/rdoc/classes/MagicUserstamp/MagicColumns/ClassMethods.html +225 -0
  22. data/rdoc/classes/MagicUserstamp/MagicUserstampError.html +111 -0
  23. data/rdoc/classes/{Ddb/Userstamp → MagicUserstamp}/MigrationHelper.html +8 -8
  24. data/rdoc/classes/MagicUserstamp/MigrationHelper/InstanceMethods.html +142 -0
  25. data/rdoc/classes/MagicUserstamp/Stampable.html +157 -0
  26. data/rdoc/classes/MagicUserstamp/Stampable/ClassMethods.html +259 -0
  27. data/rdoc/classes/{Ddb/Userstamp → MagicUserstamp}/Stamper.html +9 -9
  28. data/rdoc/classes/{Ddb/Userstamp → MagicUserstamp}/Stamper/ClassMethods.html +19 -19
  29. data/rdoc/classes/MagicUserstamp/Stamper/InstanceMethods.html +208 -0
  30. data/rdoc/created.rid +1 -1
  31. data/rdoc/files/README_rdoc.html +268 -0
  32. data/rdoc/files/lib/magic_userstamp/config_rb.html +108 -0
  33. data/rdoc/files/lib/magic_userstamp/controller_rb.html +108 -0
  34. data/rdoc/files/lib/{userstamp_rb.html → magic_userstamp/event_rb.html} +14 -7
  35. data/rdoc/files/lib/magic_userstamp/magic_columns_rb.html +108 -0
  36. data/rdoc/files/lib/{migration_helper_rb.html → magic_userstamp/migration_helper_rb.html} +12 -5
  37. data/rdoc/files/lib/magic_userstamp/stampable_rb.html +108 -0
  38. data/rdoc/files/lib/{stamper_rb.html → magic_userstamp/stamper_rb.html} +12 -5
  39. data/rdoc/files/lib/{stampable_rb.html → magic_userstamp_rb.html} +6 -6
  40. data/rdoc/fr_class_index.html +18 -13
  41. data/rdoc/fr_file_index.html +11 -9
  42. data/rdoc/fr_method_index.html +39 -9
  43. data/rdoc/index.html +7 -5
  44. data/spec/compatibility_stamping_spec.rb +3 -3
  45. data/spec/config_spec.rb +5 -5
  46. data/spec/magic_column_spec.rb +8 -8
  47. data/spec/resources/controllers/magic_userstamp_controller.rb +9 -0
  48. data/spec/resources/controllers/posts_controller.rb +2 -2
  49. data/spec/resources/controllers/users_controller.rb +2 -2
  50. data/spec/stamping_spec.rb +1 -1
  51. metadata +36 -29
  52. data/lib/userstamp.rb +0 -17
  53. data/lib/userstamp/migration_helper.rb +0 -17
  54. data/rdoc/classes/Ddb/Controller/Userstamp.html +0 -125
  55. data/rdoc/classes/Ddb/Userstamp.html +0 -121
  56. data/rdoc/classes/Ddb/Userstamp/MigrationHelper/InstanceMethods.html +0 -142
  57. data/rdoc/classes/Ddb/Userstamp/Stampable.html +0 -128
  58. data/rdoc/classes/Ddb/Userstamp/Stampable/ClassMethods.html +0 -222
  59. data/rdoc/classes/Ddb/Userstamp/Stamper/InstanceMethods.html +0 -207
  60. data/rdoc/files/CHANGELOG.html +0 -137
  61. data/rdoc/files/LICENSE.html +0 -129
  62. data/rdoc/files/README.html +0 -341
  63. data/spec/resources/controllers/userstamp_controller.rb +0 -9
@@ -1,14 +1,14 @@
1
- <?xml version="1.0" encoding="iso-8859-1"?>
1
+ <?xml version="1.0" encoding="utf-8"?>
2
2
  <!DOCTYPE html
3
3
  PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
4
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
5
 
6
6
  <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
7
  <head>
8
- <title>Module: Ddb::Userstamp::Stamper</title>
9
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
8
+ <title>Module: MagicUserstamp::Stamper</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
10
10
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
- <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
11
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
12
12
  <script type="text/javascript">
13
13
  // <![CDATA[
14
14
 
@@ -50,13 +50,13 @@
50
50
  <table class="header-table">
51
51
  <tr class="top-aligned-row">
52
52
  <td><strong>Module</strong></td>
53
- <td class="class-name-in-header">Ddb::Userstamp::Stamper</td>
53
+ <td class="class-name-in-header">MagicUserstamp::Stamper</td>
54
54
  </tr>
55
55
  <tr class="top-aligned-row">
56
56
  <td><strong>In:</strong></td>
57
57
  <td>
58
- <a href="../../../files/lib/stamper_rb.html">
59
- lib/stamper.rb
58
+ <a href="../../files/lib/magic_userstamp/stamper_rb.html">
59
+ lib/magic_userstamp/stamper.rb
60
60
  </a>
61
61
  <br />
62
62
  </td>
@@ -87,8 +87,8 @@
87
87
  <div id="class-list">
88
88
  <h3 class="section-bar">Classes and Modules</h3>
89
89
 
90
- Module <a href="Stamper/ClassMethods.html" class="link">Ddb::Userstamp::Stamper::ClassMethods</a><br />
91
- Module <a href="Stamper/InstanceMethods.html" class="link">Ddb::Userstamp::Stamper::InstanceMethods</a><br />
90
+ Module <a href="Stamper/ClassMethods.html" class="link">MagicUserstamp::Stamper::ClassMethods</a><br />
91
+ Module <a href="Stamper/InstanceMethods.html" class="link">MagicUserstamp::Stamper::InstanceMethods</a><br />
92
92
 
93
93
  </div>
94
94
 
@@ -1,14 +1,14 @@
1
- <?xml version="1.0" encoding="iso-8859-1"?>
1
+ <?xml version="1.0" encoding="utf-8"?>
2
2
  <!DOCTYPE html
3
3
  PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
4
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
5
 
6
6
  <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
7
  <head>
8
- <title>Module: Ddb::Userstamp::Stamper::ClassMethods</title>
9
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
8
+ <title>Module: MagicUserstamp::Stamper::ClassMethods</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
10
10
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
- <link rel="stylesheet" href="../../../.././rdoc-style.css" type="text/css" media="screen" />
11
+ <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
12
12
  <script type="text/javascript">
13
13
  // <![CDATA[
14
14
 
@@ -50,13 +50,13 @@
50
50
  <table class="header-table">
51
51
  <tr class="top-aligned-row">
52
52
  <td><strong>Module</strong></td>
53
- <td class="class-name-in-header">Ddb::Userstamp::Stamper::ClassMethods</td>
53
+ <td class="class-name-in-header">MagicUserstamp::Stamper::ClassMethods</td>
54
54
  </tr>
55
55
  <tr class="top-aligned-row">
56
56
  <td><strong>In:</strong></td>
57
57
  <td>
58
- <a href="../../../../files/lib/stamper_rb.html">
59
- lib/stamper.rb
58
+ <a href="../../../files/lib/magic_userstamp/stamper_rb.html">
59
+ lib/magic_userstamp/stamper.rb
60
60
  </a>
61
61
  <br />
62
62
  </td>
@@ -80,7 +80,7 @@
80
80
  <h3 class="section-bar">Methods</h3>
81
81
 
82
82
  <div class="name-list">
83
- <a href="#M000001">model_stamper</a>&nbsp;&nbsp;
83
+ <a href="#M000003">model_stamper</a>&nbsp;&nbsp;
84
84
  </div>
85
85
  </div>
86
86
 
@@ -102,26 +102,26 @@
102
102
  <div id="methods">
103
103
  <h3 class="section-bar">Public Instance methods</h3>
104
104
 
105
- <div id="method-M000001" class="method-detail">
106
- <a name="M000001"></a>
105
+ <div id="method-M000003" class="method-detail">
106
+ <a name="M000003"></a>
107
107
 
108
108
  <div class="method-heading">
109
- <a href="#M000001" class="method-signature">
109
+ <a href="#M000003" class="method-signature">
110
110
  <span class="method-name">model_stamper</span><span class="method-args">()</span>
111
111
  </a>
112
112
  </div>
113
113
 
114
114
  <div class="method-description">
115
115
  <p><a class="source-toggle" href="#"
116
- onclick="toggleCode('M000001-source');return false;">[Source]</a></p>
117
- <div class="method-source-code" id="M000001-source">
116
+ onclick="toggleCode('M000003-source');return false;">[Source]</a></p>
117
+ <div class="method-source-code" id="M000003-source">
118
118
  <pre>
119
- <span class="ruby-comment cmt"># File lib/stamper.rb, line 9</span>
120
- 9: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">model_stamper</span>
121
- 10: <span class="ruby-comment cmt"># don't allow multiple calls</span>
122
- 11: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">included_modules</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-constant">Ddb</span><span class="ruby-operator">::</span><span class="ruby-constant">Userstamp</span><span class="ruby-operator">::</span><span class="ruby-constant">Stamper</span><span class="ruby-operator">::</span><span class="ruby-constant">InstanceMethods</span>)
123
- 12: <span class="ruby-identifier">send</span>(<span class="ruby-identifier">:extend</span>, <span class="ruby-constant">Ddb</span><span class="ruby-operator">::</span><span class="ruby-constant">Userstamp</span><span class="ruby-operator">::</span><span class="ruby-constant">Stamper</span><span class="ruby-operator">::</span><span class="ruby-constant">InstanceMethods</span>)
124
- 13: <span class="ruby-keyword kw">end</span>
119
+ <span class="ruby-comment cmt"># File lib/magic_userstamp/stamper.rb, line 10</span>
120
+ 10: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">model_stamper</span>
121
+ 11: <span class="ruby-comment cmt"># don't allow multiple calls</span>
122
+ 12: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">MagicUserstamp</span><span class="ruby-operator">::</span><span class="ruby-constant">Stamper</span><span class="ruby-operator">::</span><span class="ruby-constant">InstanceMethods</span>)
123
+ 13: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">extend</span>(<span class="ruby-constant">MagicUserstamp</span><span class="ruby-operator">::</span><span class="ruby-constant">Stamper</span><span class="ruby-operator">::</span><span class="ruby-constant">InstanceMethods</span>)
124
+ 14: <span class="ruby-keyword kw">end</span>
125
125
  </pre>
126
126
  </div>
127
127
  </div>
@@ -0,0 +1,208 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
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: MagicUserstamp::Stamper::InstanceMethods</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
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">MagicUserstamp::Stamper::InstanceMethods</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ <a href="../../../files/lib/magic_userstamp/stamper_rb.html">
59
+ lib/magic_userstamp/stamper.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
+
76
+
77
+ </div>
78
+
79
+ <div id="method-list">
80
+ <h3 class="section-bar">Methods</h3>
81
+
82
+ <div class="name-list">
83
+ <a href="#M000006">reset_stamper</a>&nbsp;&nbsp;
84
+ <a href="#M000005">stamper</a>&nbsp;&nbsp;
85
+ <a href="#M000004">stamper=</a>&nbsp;&nbsp;
86
+ </div>
87
+ </div>
88
+
89
+ </div>
90
+
91
+
92
+ <!-- if includes -->
93
+
94
+ <div id="section">
95
+
96
+
97
+
98
+
99
+
100
+
101
+
102
+
103
+ <!-- if method_list -->
104
+ <div id="methods">
105
+ <h3 class="section-bar">Public Instance methods</h3>
106
+
107
+ <div id="method-M000006" class="method-detail">
108
+ <a name="M000006"></a>
109
+
110
+ <div class="method-heading">
111
+ <a href="#M000006" class="method-signature">
112
+ <span class="method-name">reset_stamper</span><span class="method-args">()</span>
113
+ </a>
114
+ </div>
115
+
116
+ <div class="method-description">
117
+ <p>
118
+ Sets the <a href="InstanceMethods.html#M000005">stamper</a> back to
119
+ <tt>nil</tt> to prepare for the next request.
120
+ </p>
121
+ <p><a class="source-toggle" href="#"
122
+ onclick="toggleCode('M000006-source');return false;">[Source]</a></p>
123
+ <div class="method-source-code" id="M000006-source">
124
+ <pre>
125
+ <span class="ruby-comment cmt"># File lib/magic_userstamp/stamper.rb, line 36</span>
126
+ 36: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">reset_stamper</span>
127
+ 37: <span class="ruby-constant">Thread</span>.<span class="ruby-identifier">current</span>[<span class="ruby-node">&quot;#{self.to_s.downcase}_#{self.object_id}_stamper&quot;</span>] = <span class="ruby-keyword kw">nil</span>
128
+ 38: <span class="ruby-keyword kw">end</span>
129
+ </pre>
130
+ </div>
131
+ </div>
132
+ </div>
133
+
134
+ <div id="method-M000005" class="method-detail">
135
+ <a name="M000005"></a>
136
+
137
+ <div class="method-heading">
138
+ <a href="#M000005" class="method-signature">
139
+ <span class="method-name">stamper</span><span class="method-args">()</span>
140
+ </a>
141
+ </div>
142
+
143
+ <div class="method-description">
144
+ <p>
145
+ Retrieves the existing <a href="InstanceMethods.html#M000005">stamper</a>
146
+ for the current request.
147
+ </p>
148
+ <p><a class="source-toggle" href="#"
149
+ onclick="toggleCode('M000005-source');return false;">[Source]</a></p>
150
+ <div class="method-source-code" id="M000005-source">
151
+ <pre>
152
+ <span class="ruby-comment cmt"># File lib/magic_userstamp/stamper.rb, line 31</span>
153
+ 31: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">stamper</span>
154
+ 32: <span class="ruby-constant">Thread</span>.<span class="ruby-identifier">current</span>[<span class="ruby-node">&quot;#{self.to_s.downcase}_#{self.object_id}_stamper&quot;</span>]
155
+ 33: <span class="ruby-keyword kw">end</span>
156
+ </pre>
157
+ </div>
158
+ </div>
159
+ </div>
160
+
161
+ <div id="method-M000004" class="method-detail">
162
+ <a name="M000004"></a>
163
+
164
+ <div class="method-heading">
165
+ <a href="#M000004" class="method-signature">
166
+ <span class="method-name">stamper=</span><span class="method-args">(object)</span>
167
+ </a>
168
+ </div>
169
+
170
+ <div class="method-description">
171
+ <p>
172
+ Used to set the <a href="InstanceMethods.html#M000005">stamper</a> for a
173
+ particular request. See the <a
174
+ href="../../MagicUserstamp.html">MagicUserstamp</a> module for more details
175
+ on how to use this method.
176
+ </p>
177
+ <p><a class="source-toggle" href="#"
178
+ onclick="toggleCode('M000004-source');return false;">[Source]</a></p>
179
+ <div class="method-source-code" id="M000004-source">
180
+ <pre>
181
+ <span class="ruby-comment cmt"># File lib/magic_userstamp/stamper.rb, line 20</span>
182
+ 20: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">stamper=</span>(<span class="ruby-identifier">object</span>)
183
+ 21: <span class="ruby-identifier">object_stamper</span> = <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">object</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">ActiveRecord</span><span class="ruby-operator">::</span><span class="ruby-constant">Base</span>)
184
+ 22: <span class="ruby-identifier">object</span>.<span class="ruby-identifier">send</span>(<span class="ruby-node">&quot;#{object.class.primary_key}&quot;</span>.<span class="ruby-identifier">to_sym</span>)
185
+ 23: <span class="ruby-keyword kw">else</span>
186
+ 24: <span class="ruby-identifier">object</span>
187
+ 25: <span class="ruby-keyword kw">end</span>
188
+ 26:
189
+ 27: <span class="ruby-constant">Thread</span>.<span class="ruby-identifier">current</span>[<span class="ruby-node">&quot;#{self.to_s.downcase}_#{self.object_id}_stamper&quot;</span>] = <span class="ruby-identifier">object_stamper</span>
190
+ 28: <span class="ruby-keyword kw">end</span>
191
+ </pre>
192
+ </div>
193
+ </div>
194
+ </div>
195
+
196
+
197
+ </div>
198
+
199
+
200
+ </div>
201
+
202
+
203
+ <div id="validator-badges">
204
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
205
+ </div>
206
+
207
+ </body>
208
+ </html>
data/rdoc/created.rid CHANGED
@@ -1 +1 @@
1
- Sat, 05 Apr 2008 15:11:35 -0600
1
+ Wed, 28 Oct 2009 19:22:13 +0900
@@ -0,0 +1,268 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
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>File: README.rdoc</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
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="fileHeader">
50
+ <h1>README.rdoc</h1>
51
+ <table class="header-table">
52
+ <tr class="top-aligned-row">
53
+ <td><strong>Path:</strong></td>
54
+ <td>README.rdoc
55
+ </td>
56
+ </tr>
57
+ <tr class="top-aligned-row">
58
+ <td><strong>Last Update:</strong></td>
59
+ <td>Wed Oct 28 19:22:06 +0900 2009</td>
60
+ </tr>
61
+ </table>
62
+ </div>
63
+ <!-- banner header -->
64
+
65
+ <div id="bodyContent">
66
+
67
+
68
+
69
+ <div id="contextContent">
70
+
71
+ <div id="description">
72
+ <h1><a href="../classes/MagicUserstamp.html">MagicUserstamp</a></h1>
73
+ <h2>Install</h2>
74
+ <h3>as a plugin</h3>
75
+ <pre>
76
+ ruby script/plugin install git://github.com/akm/magic_userstamp.git
77
+ </pre>
78
+ <h3>as a gem</h3>
79
+ <p>
80
+ insert following line to config/environment.rb
81
+ </p>
82
+ <pre>
83
+ config.gem 'magic_userstamp', :version =&gt; '0.1.0'
84
+ </pre>
85
+ <p>
86
+ and
87
+ </p>
88
+ <pre>
89
+ $ sudo rake gems:install
90
+ </pre>
91
+ <p>
92
+ Or install gem manually
93
+ </p>
94
+ <pre>
95
+ $ sudo gem install gemcutter
96
+ $ sudo gem tumble
97
+ $ sudo gem install magic_userstamp
98
+ </pre>
99
+ <h2>Simple Configuration</h2>
100
+ <p>
101
+ make config/initializers/magic_userstamp.rb
102
+ </p>
103
+ <p>
104
+ The most simple setting
105
+ </p>
106
+ <pre>
107
+ require 'magic_userstamp'
108
+ # Comment out if you don't use t.userstamp at all in migrations
109
+ ActiveRecord::ConnectionAdapters::TableDefinition.send(:include, MagicUserstamp::MigrationHelper)
110
+ ActiveRecord::Base.module_eval do
111
+ include MagicUserstamp
112
+ end
113
+
114
+ MagicUserstamp::Config.setup.defaults
115
+
116
+ # If you have some classes which has loaded before Userstamp is loaded,
117
+ # set record_userstamp true
118
+ # Example: vestal_versions gem
119
+ # Version.record_userstamp = true if defined?(Version)
120
+ </pre>
121
+ <h2>Controller setting</h2>
122
+ <p>
123
+ add followings to ApplicationController or some controller
124
+ </p>
125
+ <pre>
126
+ before_filter :set_user
127
+ after_filter :reset_user
128
+
129
+ def set_user
130
+ user_id = session[:user] # ここではIDが帰ってくるはず。
131
+ User.model_stamper # UserがIDを覚えられるようにする。
132
+ User.stamper = user_id # IDを覚えておく。stamper=にはオブジェクトを渡してもOK。
133
+ end
134
+
135
+ def reset_user
136
+ User.model_stamper # Userが覚えているIDを忘れることができるようにする。
137
+ User.reset_stamper # Userが覚えているIDを実際に忘れる。
138
+ end
139
+ </pre>
140
+ <h2>Various Configuration</h2>
141
+ <p>
142
+ If you want to customize setting, chage
143
+ config/initializers/magic_userstamp.rb
144
+ </p>
145
+ <p>
146
+ The most simple setting
147
+ </p>
148
+ <pre>
149
+ MagicUserstamp::Config.setup.defaults
150
+ </pre>
151
+ <p>
152
+ Specify User class name
153
+ </p>
154
+ <pre>
155
+ MagicUserstamp::Config.setup.defaults(:stamper_class_name =&gt; 'AdminUser')
156
+ </pre>
157
+ <p>
158
+ Actually
159
+ </p>
160
+ <pre>
161
+ MagicUserstamp::Config.setup.defaults
162
+ </pre>
163
+ <p>
164
+ means
165
+ </p>
166
+ <pre>
167
+ MagicUserstamp.config.setup do |config|
168
+ config.with_options(:stamper_class_name =&gt; 'User') do |c|
169
+ c.on(:create , :creator_id)
170
+ c.on(:update , :updater_id)
171
+ c.on(:destroy, :deleter_id)
172
+ end
173
+ end
174
+ </pre>
175
+ <p>
176
+ Specify User class name and creator/updater columns
177
+ </p>
178
+ <pre>
179
+ MagicUserstamp.config.setup do |config|
180
+ config.with_options(:stamper_class_name =&gt; 'Person') do |c|
181
+ c.on(:create , :creator_person_id)
182
+ c.on(:update , :updater_person_id)
183
+ c.on(:destroy, :deleter_person_id)
184
+ end
185
+ end
186
+ </pre>
187
+ <p>
188
+ Specify target stampable class names
189
+ </p>
190
+ <pre>
191
+ MagicUserstamp.config.setup do |config|
192
+ config.defaults(:stampable_class_names =&gt; %w(Book Schedule))
193
+ </pre>
194
+ <p>
195
+ Specify target stampable class names and columns
196
+ </p>
197
+ <pre>
198
+ MagicUserstamp.config.setup do |config|
199
+ config.with_options(:stampable_class_names =&gt; %w(Book Schedule)) do |c|
200
+ c.on(:create , :creator_user_id)
201
+ c.on(:update , :updater_user_id)
202
+ c.on(:destroy, :deleter_user_id)
203
+ end
204
+ end
205
+ </pre>
206
+ <p>
207
+ Use in compatibility mode
208
+ </p>
209
+ <pre>
210
+ MagicUserstamp.config.compatibles
211
+ </pre>
212
+ <p>
213
+ Same as
214
+ </p>
215
+ <pre>
216
+ MagicUserstamp.config.setup do |c|
217
+ c.on(:create , :created_by)
218
+ c.on(:update , :updated_by)
219
+ c.on(:destroy, :deleted_by)
220
+ end
221
+ </pre>
222
+ <p>
223
+ Complex pattern
224
+ </p>
225
+ <pre>
226
+ MagicUserstamp.config.setup do |config|
227
+ config.with_options(:stampable_class_names =&gt; %w(Book Schedule)) do |c|
228
+ c.on(:create , :creator_user_id)
229
+ c.on(:update , :updater_user_id)
230
+ c.on(:destroy, :deleter_user_id)
231
+ end
232
+ config.compatibles(:stamper_class_name =&gt; 'Person', :stampable_class_names =&gt; %w(Person Email))
233
+ config.defaults
234
+ end
235
+ </pre>
236
+
237
+ </div>
238
+
239
+
240
+ </div>
241
+
242
+
243
+ </div>
244
+
245
+
246
+ <!-- if includes -->
247
+
248
+ <div id="section">
249
+
250
+
251
+
252
+
253
+
254
+
255
+
256
+
257
+ <!-- if method_list -->
258
+
259
+
260
+ </div>
261
+
262
+
263
+ <div id="validator-badges">
264
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
265
+ </div>
266
+
267
+ </body>
268
+ </html>