magic_userstamp 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +78 -8
- data/Rakefile +2 -1
- data/VERSION +1 -1
- data/init.rb +5 -7
- data/lib/magic_userstamp.rb +27 -0
- data/lib/{userstamp → magic_userstamp}/config.rb +11 -12
- data/lib/{userstamp → magic_userstamp}/controller.rb +2 -2
- data/lib/{userstamp → magic_userstamp}/event.rb +3 -3
- data/lib/{userstamp → magic_userstamp}/magic_columns.rb +3 -3
- data/lib/magic_userstamp/migration_helper.rb +17 -0
- data/lib/{userstamp → magic_userstamp}/stampable.rb +15 -15
- data/lib/{userstamp → magic_userstamp}/stamper.rb +5 -5
- data/magic_userstamp.gemspec +36 -29
- data/rdoc/classes/MagicUserstamp.html +233 -0
- data/rdoc/classes/MagicUserstamp/Config.html +408 -0
- data/rdoc/classes/MagicUserstamp/Config/Pattern.html +246 -0
- data/rdoc/classes/{Ddb → MagicUserstamp}/Controller.html +7 -7
- data/rdoc/classes/{Ddb/Controller/Userstamp → MagicUserstamp/Controller}/InstanceMethods.html +7 -7
- data/rdoc/classes/MagicUserstamp/Event.html +367 -0
- data/rdoc/classes/MagicUserstamp/MagicColumns.html +180 -0
- data/rdoc/classes/MagicUserstamp/MagicColumns/ClassMethods.html +225 -0
- data/rdoc/classes/MagicUserstamp/MagicUserstampError.html +111 -0
- data/rdoc/classes/{Ddb/Userstamp → MagicUserstamp}/MigrationHelper.html +8 -8
- data/rdoc/classes/MagicUserstamp/MigrationHelper/InstanceMethods.html +142 -0
- data/rdoc/classes/MagicUserstamp/Stampable.html +157 -0
- data/rdoc/classes/MagicUserstamp/Stampable/ClassMethods.html +259 -0
- data/rdoc/classes/{Ddb/Userstamp → MagicUserstamp}/Stamper.html +9 -9
- data/rdoc/classes/{Ddb/Userstamp → MagicUserstamp}/Stamper/ClassMethods.html +19 -19
- data/rdoc/classes/MagicUserstamp/Stamper/InstanceMethods.html +208 -0
- data/rdoc/created.rid +1 -1
- data/rdoc/files/README_rdoc.html +268 -0
- data/rdoc/files/lib/magic_userstamp/config_rb.html +108 -0
- data/rdoc/files/lib/magic_userstamp/controller_rb.html +108 -0
- data/rdoc/files/lib/{userstamp_rb.html → magic_userstamp/event_rb.html} +14 -7
- data/rdoc/files/lib/magic_userstamp/magic_columns_rb.html +108 -0
- data/rdoc/files/lib/{migration_helper_rb.html → magic_userstamp/migration_helper_rb.html} +12 -5
- data/rdoc/files/lib/magic_userstamp/stampable_rb.html +108 -0
- data/rdoc/files/lib/{stamper_rb.html → magic_userstamp/stamper_rb.html} +12 -5
- data/rdoc/files/lib/{stampable_rb.html → magic_userstamp_rb.html} +6 -6
- data/rdoc/fr_class_index.html +18 -13
- data/rdoc/fr_file_index.html +11 -9
- data/rdoc/fr_method_index.html +39 -9
- data/rdoc/index.html +7 -5
- data/spec/compatibility_stamping_spec.rb +3 -3
- data/spec/config_spec.rb +5 -5
- data/spec/magic_column_spec.rb +8 -8
- data/spec/resources/controllers/magic_userstamp_controller.rb +9 -0
- data/spec/resources/controllers/posts_controller.rb +2 -2
- data/spec/resources/controllers/users_controller.rb +2 -2
- data/spec/stamping_spec.rb +1 -1
- metadata +36 -29
- data/lib/userstamp.rb +0 -17
- data/lib/userstamp/migration_helper.rb +0 -17
- data/rdoc/classes/Ddb/Controller/Userstamp.html +0 -125
- data/rdoc/classes/Ddb/Userstamp.html +0 -121
- data/rdoc/classes/Ddb/Userstamp/MigrationHelper/InstanceMethods.html +0 -142
- data/rdoc/classes/Ddb/Userstamp/Stampable.html +0 -128
- data/rdoc/classes/Ddb/Userstamp/Stampable/ClassMethods.html +0 -222
- data/rdoc/classes/Ddb/Userstamp/Stamper/InstanceMethods.html +0 -207
- data/rdoc/files/CHANGELOG.html +0 -137
- data/rdoc/files/LICENSE.html +0 -129
- data/rdoc/files/README.html +0 -341
- data/spec/resources/controllers/userstamp_controller.rb +0 -9
@@ -1,14 +1,14 @@
|
|
1
|
-
<?xml version="1.0" encoding="
|
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:
|
9
|
-
<meta http-equiv="Content-Type" content="text/html; charset=
|
8
|
+
<title>Module: MagicUserstamp::MigrationHelper</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="
|
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">
|
53
|
+
<td class="class-name-in-header">MagicUserstamp::MigrationHelper</td>
|
54
54
|
</tr>
|
55
55
|
<tr class="top-aligned-row">
|
56
56
|
<td><strong>In:</strong></td>
|
57
57
|
<td>
|
58
|
-
<a href="
|
59
|
-
lib/migration_helper.rb
|
58
|
+
<a href="../../files/lib/magic_userstamp/migration_helper_rb.html">
|
59
|
+
lib/magic_userstamp/migration_helper.rb
|
60
60
|
</a>
|
61
61
|
<br />
|
62
62
|
</td>
|
@@ -87,7 +87,7 @@
|
|
87
87
|
<div id="class-list">
|
88
88
|
<h3 class="section-bar">Classes and Modules</h3>
|
89
89
|
|
90
|
-
Module <a href="MigrationHelper/InstanceMethods.html" class="link">
|
90
|
+
Module <a href="MigrationHelper/InstanceMethods.html" class="link">MagicUserstamp::MigrationHelper::InstanceMethods</a><br />
|
91
91
|
|
92
92
|
</div>
|
93
93
|
|
@@ -0,0 +1,142 @@
|
|
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::MigrationHelper::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::MigrationHelper::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/migration_helper_rb.html">
|
59
|
+
lib/magic_userstamp/migration_helper.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="#M000016">userstamps</a>
|
84
|
+
</div>
|
85
|
+
</div>
|
86
|
+
|
87
|
+
</div>
|
88
|
+
|
89
|
+
|
90
|
+
<!-- if includes -->
|
91
|
+
|
92
|
+
<div id="section">
|
93
|
+
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
<!-- if method_list -->
|
102
|
+
<div id="methods">
|
103
|
+
<h3 class="section-bar">Public Instance methods</h3>
|
104
|
+
|
105
|
+
<div id="method-M000016" class="method-detail">
|
106
|
+
<a name="M000016"></a>
|
107
|
+
|
108
|
+
<div class="method-heading">
|
109
|
+
<a href="#M000016" class="method-signature">
|
110
|
+
<span class="method-name">userstamps</span><span class="method-args">(include_deleted_by = false)</span>
|
111
|
+
</a>
|
112
|
+
</div>
|
113
|
+
|
114
|
+
<div class="method-description">
|
115
|
+
<p><a class="source-toggle" href="#"
|
116
|
+
onclick="toggleCode('M000016-source');return false;">[Source]</a></p>
|
117
|
+
<div class="method-source-code" id="M000016-source">
|
118
|
+
<pre>
|
119
|
+
<span class="ruby-comment cmt"># File lib/magic_userstamp/migration_helper.rb, line 10</span>
|
120
|
+
10: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">userstamps</span>(<span class="ruby-identifier">include_deleted_by</span> = <span class="ruby-keyword kw">false</span>)
|
121
|
+
11: <span class="ruby-identifier">column</span>(<span class="ruby-constant">MagicUserstamp</span>.<span class="ruby-identifier">compatibility_mode</span> <span class="ruby-value">? </span><span class="ruby-operator">:</span><span class="ruby-identifier">created_by</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">:creator_id</span>, <span class="ruby-identifier">:integer</span>)
|
122
|
+
12: <span class="ruby-identifier">column</span>(<span class="ruby-constant">MagicUserstamp</span>.<span class="ruby-identifier">compatibility_mode</span> <span class="ruby-value">? </span><span class="ruby-operator">:</span><span class="ruby-identifier">updated_by</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">:updater_id</span>, <span class="ruby-identifier">:integer</span>)
|
123
|
+
13: <span class="ruby-identifier">column</span>(<span class="ruby-constant">MagicUserstamp</span>.<span class="ruby-identifier">compatibility_mode</span> <span class="ruby-value">? </span><span class="ruby-operator">:</span><span class="ruby-identifier">deleted_by</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">:deleter_id</span>, <span class="ruby-identifier">:integer</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">include_deleted_by</span>
|
124
|
+
14: <span class="ruby-keyword kw">end</span>
|
125
|
+
</pre>
|
126
|
+
</div>
|
127
|
+
</div>
|
128
|
+
</div>
|
129
|
+
|
130
|
+
|
131
|
+
</div>
|
132
|
+
|
133
|
+
|
134
|
+
</div>
|
135
|
+
|
136
|
+
|
137
|
+
<div id="validator-badges">
|
138
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
139
|
+
</div>
|
140
|
+
|
141
|
+
</body>
|
142
|
+
</html>
|
@@ -0,0 +1,157 @@
|
|
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::Stampable</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::Stampable</td>
|
54
|
+
</tr>
|
55
|
+
<tr class="top-aligned-row">
|
56
|
+
<td><strong>In:</strong></td>
|
57
|
+
<td>
|
58
|
+
<a href="../../files/lib/magic_userstamp/stampable_rb.html">
|
59
|
+
lib/magic_userstamp/stampable.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
|
+
Extends the stamping functionality of ActiveRecord by automatically
|
78
|
+
recording the model responsible for creating, updating, and deleting the
|
79
|
+
current object. See the <a href="Stamper.html">Stamper</a> and Userstamp
|
80
|
+
modules for further documentation on how the entire process works.
|
81
|
+
</p>
|
82
|
+
|
83
|
+
</div>
|
84
|
+
|
85
|
+
|
86
|
+
</div>
|
87
|
+
|
88
|
+
<div id="method-list">
|
89
|
+
<h3 class="section-bar">Methods</h3>
|
90
|
+
|
91
|
+
<div class="name-list">
|
92
|
+
<a href="#M000012">raise_unless_valid_options_for_stampable_on</a>
|
93
|
+
</div>
|
94
|
+
</div>
|
95
|
+
|
96
|
+
</div>
|
97
|
+
|
98
|
+
|
99
|
+
<!-- if includes -->
|
100
|
+
|
101
|
+
<div id="section">
|
102
|
+
|
103
|
+
<div id="class-list">
|
104
|
+
<h3 class="section-bar">Classes and Modules</h3>
|
105
|
+
|
106
|
+
Module <a href="Stampable/ClassMethods.html" class="link">MagicUserstamp::Stampable::ClassMethods</a><br />
|
107
|
+
|
108
|
+
</div>
|
109
|
+
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
|
116
|
+
<!-- if method_list -->
|
117
|
+
<div id="methods">
|
118
|
+
<h3 class="section-bar">Public Class methods</h3>
|
119
|
+
|
120
|
+
<div id="method-M000012" class="method-detail">
|
121
|
+
<a name="M000012"></a>
|
122
|
+
|
123
|
+
<div class="method-heading">
|
124
|
+
<a href="#M000012" class="method-signature">
|
125
|
+
<span class="method-name">raise_unless_valid_options_for_stampable_on</span><span class="method-args">(options)</span>
|
126
|
+
</a>
|
127
|
+
</div>
|
128
|
+
|
129
|
+
<div class="method-description">
|
130
|
+
<p><a class="source-toggle" href="#"
|
131
|
+
onclick="toggleCode('M000012-source');return false;">[Source]</a></p>
|
132
|
+
<div class="method-source-code" id="M000012-source">
|
133
|
+
<pre>
|
134
|
+
<span class="ruby-comment cmt"># File lib/magic_userstamp/stampable.rb, line 41</span>
|
135
|
+
41: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">raise_unless_valid_options_for_stampable_on</span>(<span class="ruby-identifier">options</span>)
|
136
|
+
42: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>.<span class="ruby-identifier">nil?</span>
|
137
|
+
43: <span class="ruby-identifier">invalid_keys</span> = (<span class="ruby-identifier">options</span>.<span class="ruby-identifier">keys</span> <span class="ruby-operator">-</span> <span class="ruby-constant">VALID_OPTIONS_KEYS_FOR_STAMPABLE_ON</span>)
|
138
|
+
44: <span class="ruby-identifier">raise</span> <span class="ruby-node">"Invalid options keys: #{invalid_keys.inspect}"</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">invalid_keys</span>.<span class="ruby-identifier">empty?</span>
|
139
|
+
45: <span class="ruby-keyword kw">end</span>
|
140
|
+
</pre>
|
141
|
+
</div>
|
142
|
+
</div>
|
143
|
+
</div>
|
144
|
+
|
145
|
+
|
146
|
+
</div>
|
147
|
+
|
148
|
+
|
149
|
+
</div>
|
150
|
+
|
151
|
+
|
152
|
+
<div id="validator-badges">
|
153
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
154
|
+
</div>
|
155
|
+
|
156
|
+
</body>
|
157
|
+
</html>
|
@@ -0,0 +1,259 @@
|
|
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::Stampable::ClassMethods</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::Stampable::ClassMethods</td>
|
54
|
+
</tr>
|
55
|
+
<tr class="top-aligned-row">
|
56
|
+
<td><strong>In:</strong></td>
|
57
|
+
<td>
|
58
|
+
<a href="../../../files/lib/magic_userstamp/stampable_rb.html">
|
59
|
+
lib/magic_userstamp/stampable.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="#M000013">stampable</a>
|
84
|
+
<a href="#M000014">stampable_on</a>
|
85
|
+
<a href="#M000015">without_stamps</a>
|
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-M000013" class="method-detail">
|
108
|
+
<a name="M000013"></a>
|
109
|
+
|
110
|
+
<div class="method-heading">
|
111
|
+
<a href="#M000013" class="method-signature">
|
112
|
+
<span class="method-name">stampable</span><span class="method-args">(options = {})</span>
|
113
|
+
</a>
|
114
|
+
</div>
|
115
|
+
|
116
|
+
<div class="method-description">
|
117
|
+
<p>
|
118
|
+
This method is automatically called on for all classes that inherit from
|
119
|
+
ActiveRecord, but if you need to customize how the plug-in functions, this
|
120
|
+
is the method to use. Here‘s an example:
|
121
|
+
</p>
|
122
|
+
<pre>
|
123
|
+
class Post < ActiveRecord::Base
|
124
|
+
stampable :stamper_class_name => :person,
|
125
|
+
:creator_attribute => :create_user,
|
126
|
+
:updater_attribute => :update_user,
|
127
|
+
:deleter_attribute => :delete_user
|
128
|
+
end
|
129
|
+
</pre>
|
130
|
+
<p>
|
131
|
+
The method will automatically setup all the associations, and create
|
132
|
+
<tt>before_save</tt> and <tt>before_create</tt> filters for doing the
|
133
|
+
stamping.
|
134
|
+
</p>
|
135
|
+
<p><a class="source-toggle" href="#"
|
136
|
+
onclick="toggleCode('M000013-source');return false;">[Source]</a></p>
|
137
|
+
<div class="method-source-code" id="M000013-source">
|
138
|
+
<pre>
|
139
|
+
<span class="ruby-comment cmt"># File lib/magic_userstamp/stampable.rb, line 61</span>
|
140
|
+
61: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">stampable</span>(<span class="ruby-identifier">options</span> = {})
|
141
|
+
62: <span class="ruby-identifier">reader_name</span> = <span class="ruby-constant">MagicUserstamp</span>.<span class="ruby-identifier">compatibility_mode</span> <span class="ruby-value">? </span><span class="ruby-operator">:</span><span class="ruby-identifier">default_attribute_compatible</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">:default_attribute</span>
|
142
|
+
63: <span class="ruby-identifier">options</span> = {
|
143
|
+
64: <span class="ruby-identifier">:stamper_class_name</span> =<span class="ruby-operator">></span> <span class="ruby-value str">"User"</span>,
|
144
|
+
65: <span class="ruby-identifier">:creator_attribute</span> =<span class="ruby-operator">></span> <span class="ruby-constant">Event</span>[<span class="ruby-identifier">:create</span> ].<span class="ruby-identifier">send</span>(<span class="ruby-identifier">reader_name</span>),
|
145
|
+
66: <span class="ruby-identifier">:updater_attribute</span> =<span class="ruby-operator">></span> <span class="ruby-constant">Event</span>[<span class="ruby-identifier">:update</span> ].<span class="ruby-identifier">send</span>(<span class="ruby-identifier">reader_name</span>),
|
146
|
+
67: <span class="ruby-identifier">:deleter_attribute</span> =<span class="ruby-operator">></span> <span class="ruby-constant">Event</span>[<span class="ruby-identifier">:destroy</span>].<span class="ruby-identifier">send</span>(<span class="ruby-identifier">reader_name</span>)
|
147
|
+
68: }.<span class="ruby-identifier">update</span>(<span class="ruby-identifier">options</span> <span class="ruby-operator">||</span> {})
|
148
|
+
69:
|
149
|
+
70: <span class="ruby-identifier">stamper_class_name</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:stamper_class_name</span>].<span class="ruby-identifier">to_s</span>
|
150
|
+
71: <span class="ruby-identifier">stamper_class_name</span> = <span class="ruby-identifier">stamper_class_name</span>.<span class="ruby-identifier">camelize</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">stamper_class_name</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/^[A-Z]/</span>
|
151
|
+
72:
|
152
|
+
73: <span class="ruby-identifier">with_options</span>(<span class="ruby-identifier">:stamper_class_name</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">stamper_class_name</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">s</span><span class="ruby-operator">|</span>
|
153
|
+
74: <span class="ruby-identifier">s</span>.<span class="ruby-identifier">stampable_on</span>(<span class="ruby-identifier">:create</span> , <span class="ruby-identifier">:attribute</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:creator_attribute</span>])
|
154
|
+
75: <span class="ruby-identifier">s</span>.<span class="ruby-identifier">stampable_on</span>(<span class="ruby-identifier">:update</span> , <span class="ruby-identifier">:attribute</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:updater_attribute</span>])
|
155
|
+
76: <span class="ruby-identifier">s</span>.<span class="ruby-identifier">stampable_on</span>(<span class="ruby-identifier">:destroy</span>, <span class="ruby-identifier">:attribute</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:deleter_attribute</span>]) <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">defined?</span>(<span class="ruby-constant">Caboose</span><span class="ruby-operator">::</span><span class="ruby-constant">Acts</span><span class="ruby-operator">::</span><span class="ruby-constant">Paranoid</span>)
|
156
|
+
77: <span class="ruby-keyword kw">end</span>
|
157
|
+
78: <span class="ruby-keyword kw">end</span>
|
158
|
+
</pre>
|
159
|
+
</div>
|
160
|
+
</div>
|
161
|
+
</div>
|
162
|
+
|
163
|
+
<div id="method-M000014" class="method-detail">
|
164
|
+
<a name="M000014"></a>
|
165
|
+
|
166
|
+
<div class="method-heading">
|
167
|
+
<a href="#M000014" class="method-signature">
|
168
|
+
<span class="method-name">stampable_on</span><span class="method-args">(event_name, options = {})</span>
|
169
|
+
</a>
|
170
|
+
</div>
|
171
|
+
|
172
|
+
<div class="method-description">
|
173
|
+
<p><a class="source-toggle" href="#"
|
174
|
+
onclick="toggleCode('M000014-source');return false;">[Source]</a></p>
|
175
|
+
<div class="method-source-code" id="M000014-source">
|
176
|
+
<pre>
|
177
|
+
<span class="ruby-comment cmt"># File lib/magic_userstamp/stampable.rb, line 80</span>
|
178
|
+
80: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">stampable_on</span>(<span class="ruby-identifier">event_name</span>, <span class="ruby-identifier">options</span> = {})
|
179
|
+
81: <span class="ruby-constant">MagicUserstamp</span><span class="ruby-operator">::</span><span class="ruby-constant">Stampable</span>.<span class="ruby-identifier">raise_unless_valid_options_for_stampable_on</span>(<span class="ruby-identifier">options</span>)
|
180
|
+
82: <span class="ruby-identifier">event</span> = <span class="ruby-constant">Event</span>[<span class="ruby-identifier">event_name</span>]
|
181
|
+
83: <span class="ruby-identifier">reader_name</span> = <span class="ruby-constant">MagicUserstamp</span>.<span class="ruby-identifier">compatibility_mode</span> <span class="ruby-value">? </span><span class="ruby-operator">:</span><span class="ruby-identifier">default_attribute_compatible</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">:default_attribute</span>
|
182
|
+
84: <span class="ruby-identifier">options</span> = {
|
183
|
+
85: <span class="ruby-identifier">:stamper_name</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">event</span>.<span class="ruby-identifier">actor</span>,
|
184
|
+
86: <span class="ruby-identifier">:stamper_class_name</span> =<span class="ruby-operator">></span> <span class="ruby-value str">"User"</span>,
|
185
|
+
87: <span class="ruby-comment cmt"># :stamper_attribute => nil</span>
|
186
|
+
88: <span class="ruby-identifier">:attribute</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">event</span>.<span class="ruby-identifier">send</span>(<span class="ruby-identifier">reader_name</span>),
|
187
|
+
89: <span class="ruby-identifier">:actual_hook</span> =<span class="ruby-operator">></span> <span class="ruby-keyword kw">nil</span>
|
188
|
+
90: }.<span class="ruby-identifier">update</span>(<span class="ruby-identifier">options</span> <span class="ruby-operator">||</span> {})
|
189
|
+
91:
|
190
|
+
92: <span class="ruby-identifier">belongs_to_class_name</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:stamper_class_name</span>].<span class="ruby-identifier">to_s</span>
|
191
|
+
93: <span class="ruby-identifier">belongs_to_class_name</span> = <span class="ruby-identifier">belongs_to_class_name</span>.<span class="ruby-identifier">singularize</span>.<span class="ruby-identifier">camelize</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">belongs_to_class_name</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/^[A-Z]/</span>
|
192
|
+
94: <span class="ruby-identifier">callback_method_name</span> = <span class="ruby-node">"set_#{options[:attribute]}_on_#{event.name}"</span>
|
193
|
+
95:
|
194
|
+
96: <span class="ruby-identifier">line_no</span> = <span class="ruby-keyword kw">__LINE__</span> <span class="ruby-operator">+</span> <span class="ruby-value">2</span>
|
195
|
+
97: <span class="ruby-identifier">method_definitions</span> = <span class="ruby-value str">"belongs_to(:\#{options[:stamper_name]},\n:class_name => '\#{belongs_to_class_name}',\n:foreign_key => '\#{options[:attribute].to_s}')\n\n\#{options[:actual_hook] || event.actual_hook} :\#{callback_method_name}\n\ndef \#{callback_method_name}\nif MagicUserstamp.config.verbose?(self.class, \"\#{options[:attribute]}\") && !self.record_userstamp\nlogger.debug(\"aborting \#{self.name}.\#{callback_method_name} cause of record_userstamp is \#{self.record_userstamp.inspect}\")\nend\nreturn unless self.record_userstamp\nif RAILS_ENV == 'development'\n@@\#{options[:attribute]}_stamper_class = \"\#{options[:stamper_class_name]}\".constantize\nelse\n@@\#{options[:attribute]}_stamper_class ||= \"\#{options[:stamper_class_name]}\".constantize\nend\nstamper_class = @@\#{options[:attribute]}_stamper_class\nstamper_class.model_stamper if stamper_class\nstamper = stamper_class.stamper if stamper_class\nsend(\"\#{options[:attribute]}=\", stamper) if stamper\n\#{event.after_callback}\nend\n"</span>
|
196
|
+
98: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">MagicUserstamp</span>.<span class="ruby-identifier">config</span>.<span class="ruby-identifier">verbose?</span>(<span class="ruby-keyword kw">self</span>, <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:attribute</span>])
|
197
|
+
99: <span class="ruby-constant">ActiveRecord</span><span class="ruby-operator">::</span><span class="ruby-constant">Base</span>.<span class="ruby-identifier">logger</span>.<span class="ruby-identifier">debug</span> <span class="ruby-value str">"="</span> <span class="ruby-operator">*</span> <span class="ruby-value">100</span>
|
198
|
+
100: <span class="ruby-constant">ActiveRecord</span><span class="ruby-operator">::</span><span class="ruby-constant">Base</span>.<span class="ruby-identifier">logger</span>.<span class="ruby-identifier">debug</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">name</span>
|
199
|
+
101: <span class="ruby-constant">ActiveRecord</span><span class="ruby-operator">::</span><span class="ruby-constant">Base</span>.<span class="ruby-identifier">logger</span>.<span class="ruby-identifier">debug</span> <span class="ruby-identifier">method_definitions</span>
|
200
|
+
102: <span class="ruby-keyword kw">end</span>
|
201
|
+
103: <span class="ruby-identifier">module_eval</span>(<span class="ruby-identifier">method_definitions</span>, <span class="ruby-keyword kw">__FILE__</span>, <span class="ruby-identifier">line_no</span>)
|
202
|
+
104: <span class="ruby-keyword kw">end</span>
|
203
|
+
</pre>
|
204
|
+
</div>
|
205
|
+
</div>
|
206
|
+
</div>
|
207
|
+
|
208
|
+
<div id="method-M000015" class="method-detail">
|
209
|
+
<a name="M000015"></a>
|
210
|
+
|
211
|
+
<div class="method-heading">
|
212
|
+
<a href="#M000015" class="method-signature">
|
213
|
+
<span class="method-name">without_stamps</span><span class="method-args">() {|| ...}</span>
|
214
|
+
</a>
|
215
|
+
</div>
|
216
|
+
|
217
|
+
<div class="method-description">
|
218
|
+
<p>
|
219
|
+
Temporarily allows you to turn stamping off. For example:
|
220
|
+
</p>
|
221
|
+
<pre>
|
222
|
+
Post.without_stamps do
|
223
|
+
post = Post.find(params[:id])
|
224
|
+
post.update_attributes(params[:post])
|
225
|
+
post.save
|
226
|
+
end
|
227
|
+
</pre>
|
228
|
+
<p><a class="source-toggle" href="#"
|
229
|
+
onclick="toggleCode('M000015-source');return false;">[Source]</a></p>
|
230
|
+
<div class="method-source-code" id="M000015-source">
|
231
|
+
<pre>
|
232
|
+
<span class="ruby-comment cmt"># File lib/magic_userstamp/stampable.rb, line 137</span>
|
233
|
+
137: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">without_stamps</span>
|
234
|
+
138: <span class="ruby-identifier">original_value</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">record_userstamp</span>
|
235
|
+
139: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">record_userstamp</span> = <span class="ruby-keyword kw">false</span>
|
236
|
+
140: <span class="ruby-keyword kw">begin</span>
|
237
|
+
141: <span class="ruby-keyword kw">yield</span>
|
238
|
+
142: <span class="ruby-keyword kw">ensure</span>
|
239
|
+
143: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">record_userstamp</span> = <span class="ruby-identifier">original_value</span>
|
240
|
+
144: <span class="ruby-keyword kw">end</span>
|
241
|
+
145: <span class="ruby-keyword kw">end</span>
|
242
|
+
</pre>
|
243
|
+
</div>
|
244
|
+
</div>
|
245
|
+
</div>
|
246
|
+
|
247
|
+
|
248
|
+
</div>
|
249
|
+
|
250
|
+
|
251
|
+
</div>
|
252
|
+
|
253
|
+
|
254
|
+
<div id="validator-badges">
|
255
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
256
|
+
</div>
|
257
|
+
|
258
|
+
</body>
|
259
|
+
</html>
|