userstamp 2.0.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +9 -0
- data/Gemfile.lock +35 -0
- data/Rakefile +2 -2
- data/{README → Readme.rdoc} +27 -35
- data/VERSION +1 -1
- data/lib/stampable.rb +18 -15
- data/lib/userstamp.rb +4 -0
- data/rdoc/classes/Ddb/Userstamp.html +4 -4
- data/rdoc/classes/Ddb/Userstamp/Stampable/ClassMethods.html +41 -38
- data/rdoc/classes/Ddb/Userstamp/Stamper/InstanceMethods.html +1 -1
- data/rdoc/classes/Userstamp.html +118 -0
- data/rdoc/created.rid +1 -1
- data/rdoc/files/CHANGELOG.html +1 -1
- data/rdoc/files/LICENSE.html +1 -1
- data/rdoc/files/{README.html → Readme_rdoc.html} +62 -61
- data/rdoc/files/lib/migration_helper_rb.html +1 -1
- data/rdoc/files/lib/stampable_rb.html +1 -1
- data/rdoc/files/lib/stamper_rb.html +1 -1
- data/rdoc/files/lib/userstamp_rb.html +10 -1
- data/rdoc/fr_class_index.html +1 -0
- data/rdoc/fr_file_index.html +1 -1
- data/rdoc/index.html +1 -1
- data/test/compatibility_stamping_test.rb +29 -23
- data/test/helper.rb +61 -0
- data/test/models/comment.rb +1 -0
- data/test/models/foo.rb +3 -0
- data/test/models/post.rb +10 -1
- data/test/schema.rb +6 -8
- data/test/stamping_test.rb +45 -17
- data/test/userstamp_controller_test.rb +24 -39
- data/test/userstamp_test.rb +7 -0
- data/userstamp.gemspec +21 -24
- metadata +28 -24
- data/test/database.yml +0 -4
- data/test/fixtures/comments.yml +0 -16
- data/test/fixtures/people.yml +0 -11
- data/test/fixtures/posts.yml +0 -9
- data/test/fixtures/users.yml +0 -7
- data/test/helpers/functional_test_helper.rb +0 -37
- data/test/helpers/unit_test_helper.rb +0 -29
- data/test/models/ping.rb +0 -7
data/Gemfile
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
source 'http://rubygems.org'
|
2
|
+
|
3
|
+
gem 'rake'
|
4
|
+
gem 'redgreen'
|
5
|
+
gem 'jeweler'
|
6
|
+
gem 'activerecord', :require => 'active_record'
|
7
|
+
gem 'activesupport', :require => 'active_support'
|
8
|
+
gem 'actionpack', :require => 'action_pack'
|
9
|
+
gem 'sqlite3-ruby', :require => 'sqlite3'
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
actionpack (2.3.8)
|
5
|
+
activesupport (= 2.3.8)
|
6
|
+
rack (~> 1.1.0)
|
7
|
+
activerecord (2.3.8)
|
8
|
+
activesupport (= 2.3.8)
|
9
|
+
activesupport (2.3.8)
|
10
|
+
gemcutter (0.5.0)
|
11
|
+
json_pure
|
12
|
+
git (1.2.5)
|
13
|
+
jeweler (1.4.0)
|
14
|
+
gemcutter (>= 0.1.0)
|
15
|
+
git (>= 1.2.5)
|
16
|
+
rubyforge (>= 2.0.0)
|
17
|
+
json_pure (1.4.3)
|
18
|
+
rack (1.1.0)
|
19
|
+
rake (0.8.7)
|
20
|
+
redgreen (1.2.2)
|
21
|
+
rubyforge (2.0.4)
|
22
|
+
json_pure (>= 1.1.7)
|
23
|
+
sqlite3-ruby (1.2.5)
|
24
|
+
|
25
|
+
PLATFORMS
|
26
|
+
ruby
|
27
|
+
|
28
|
+
DEPENDENCIES
|
29
|
+
actionpack
|
30
|
+
activerecord
|
31
|
+
activesupport
|
32
|
+
jeweler
|
33
|
+
rake
|
34
|
+
redgreen
|
35
|
+
sqlite3-ruby
|
data/Rakefile
CHANGED
@@ -17,7 +17,7 @@ Rake::RDocTask.new(:rdoc) do |rdoc|
|
|
17
17
|
rdoc.rdoc_dir = 'rdoc'
|
18
18
|
rdoc.title = 'Userstamp'
|
19
19
|
rdoc.options << '--line-numbers' << '--inline-source'
|
20
|
-
rdoc.rdoc_files.include('
|
20
|
+
rdoc.rdoc_files.include('Readme.rdoc', 'CHANGELOG', 'LICENSE')
|
21
21
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
22
22
|
end
|
23
23
|
|
@@ -34,5 +34,5 @@ begin
|
|
34
34
|
|
35
35
|
Jeweler::GemcutterTasks.new
|
36
36
|
rescue LoadError
|
37
|
-
puts "Jeweler, or one of its dependencies, is not available. Install it with:
|
37
|
+
puts "Jeweler, or one of its dependencies, is not available. Install it with: gem install jeweler"
|
38
38
|
end
|
data/{README → Readme.rdoc}
RENAMED
@@ -1,8 +1,8 @@
|
|
1
|
-
|
1
|
+
Userstamp
|
2
2
|
|
3
3
|
== Overview
|
4
4
|
|
5
|
-
|
5
|
+
Userstamp extends ActiveRecord::Base[http://api.rubyonrails.com/classes/ActiveRecord/Base.html] to add automatic updating of 'creator',
|
6
6
|
'updater', and 'deleter' attributes. It is based loosely on the ActiveRecord::Timestamp[http://api.rubyonrails.com/classes/ActiveRecord/Timestamp.html] module.
|
7
7
|
|
8
8
|
Two class methods (<tt>model_stamper</tt> and <tt>stampable</tt>) are implemented in this plugin.
|
@@ -13,62 +13,53 @@ created, updated, or deleted by 'stampers'.
|
|
13
13
|
|
14
14
|
== Installation
|
15
15
|
- As Rails plugin: `script/plugin install git://github.com/delynn/userstamp.git `
|
16
|
-
- As gem: ` sudo gem install userstamp
|
17
|
-
|
18
|
-
Once installed you will need to restart your application for the plugin to be loaded into the Rails
|
19
|
-
environment.
|
20
|
-
|
21
|
-
You might also be interested in using Piston[http://piston.rubyforge.org/index.html] to manage the
|
22
|
-
importing and future updating of this plugin.
|
16
|
+
- As gem: ` sudo gem install userstamp `
|
23
17
|
|
24
18
|
== Usage
|
25
|
-
|
26
|
-
categories of objects; those that
|
19
|
+
The assumption is that you have two different
|
20
|
+
categories of objects; those that manipulate, and those that are manipulated. For those objects
|
27
21
|
that are being manipulated there's the Stampable module and for the manipulators there's the
|
28
22
|
Stamper module. There's also the actual Userstamp module for your controllers that assists in
|
29
23
|
setting up your environment on a per request basis.
|
30
24
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
method for very easily doing this:
|
25
|
+
=== Example
|
26
|
+
Assume a weblog application has User and Post objects.
|
27
|
+
1. Create the migrations for these objects
|
35
28
|
|
36
29
|
class CreateUsers < ActiveRecord::Migration
|
37
30
|
def self.up
|
38
31
|
create_table :users, :force => true do |t|
|
39
|
-
|
40
|
-
t.userstamps
|
41
|
-
t.name
|
32
|
+
...
|
33
|
+
t.userstamps # use t.userstamps(true) if you also want 'deleter_id'
|
42
34
|
end
|
43
35
|
end
|
44
|
-
|
36
|
+
|
45
37
|
def self.down
|
46
38
|
drop_table :users
|
47
39
|
end
|
48
40
|
end
|
49
|
-
|
41
|
+
|
50
42
|
class CreatePosts < ActiveRecord::Migration
|
51
43
|
def self.up
|
52
44
|
create_table :posts, :force => true do |t|
|
53
|
-
|
54
|
-
t.userstamps
|
55
|
-
t.title
|
45
|
+
...
|
46
|
+
t.userstamps # use t.userstamps(true) if you also want 'deleter_id'
|
56
47
|
end
|
57
48
|
end
|
58
|
-
|
49
|
+
|
59
50
|
def self.down
|
60
51
|
drop_table :posts
|
61
52
|
end
|
62
53
|
end
|
63
54
|
|
64
|
-
|
65
|
-
<tt>model_stamper</tt
|
55
|
+
2. Users are going to manipulate Post's, use the
|
56
|
+
<tt>model_stamper</tt>:
|
66
57
|
|
67
58
|
class User < ActiveRecord::Base
|
68
59
|
model_stamper
|
69
60
|
end
|
70
61
|
|
71
|
-
|
62
|
+
3. Setup a controller to set the current user of the application. It's
|
72
63
|
recommended that you do this in your ApplicationController:
|
73
64
|
|
74
65
|
class ApplicationController < ActionController::Base
|
@@ -106,9 +97,6 @@ User class. They are #stamper= and #stamper and look like this:
|
|
106
97
|
Thread.current["#{self.to_s.downcase}_#{self.object_id}_stamper"]
|
107
98
|
end
|
108
99
|
|
109
|
-
The big change with this new version is that we are now using Thread.current to save the current
|
110
|
-
stamper so as to avoid conflict with concurrent requests.
|
111
|
-
|
112
100
|
The <tt>stampable</tt> method allows you to customize what columns will get stamped, and also
|
113
101
|
creates the +creator+, +updater+, and +deleter+ associations.
|
114
102
|
|
@@ -131,10 +119,10 @@ If you need to customize the columns that are stamped, the <tt>stampable</tt> me
|
|
131
119
|
completely customized. Here's an quick example:
|
132
120
|
|
133
121
|
class Post < ActiveRecord::Base
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
122
|
+
stampable :stamper_class_name => :person,
|
123
|
+
:creator_attribute => :create_user,
|
124
|
+
:updater_attribute => :update_user,
|
125
|
+
:deleter_attribute => :delete_user
|
138
126
|
end
|
139
127
|
|
140
128
|
If you are upgrading your application from the old version of Userstamp, there is a compatibility
|
@@ -174,4 +162,8 @@ to merge any changes from other people's branches that would be beneficial to th
|
|
174
162
|
|
175
163
|
== Credits and Special Thanks
|
176
164
|
The original idea for this plugin came from the Rails Wiki article entitled
|
177
|
-
{Extending ActiveRecord}[http://wiki.rubyonrails.com/rails/pages/ExtendingActiveRecordExample].
|
165
|
+
{Extending ActiveRecord}[http://wiki.rubyonrails.com/rails/pages/ExtendingActiveRecordExample].
|
166
|
+
|
167
|
+
== Contributors / maintenance / enhancement
|
168
|
+
- {Michael Grosser}[http://pragmatig.com]
|
169
|
+
- {John Dell}[http://blog.spovich.com/]
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.0.
|
1
|
+
2.0.1
|
data/lib/stampable.rb
CHANGED
@@ -61,17 +61,22 @@ module Ddb #:nodoc:
|
|
61
61
|
# :creator_attribute => :create_user,
|
62
62
|
# :updater_attribute => :update_user,
|
63
63
|
# :deleter_attribute => :delete_user
|
64
|
+
# :deleter => true
|
64
65
|
# end
|
65
66
|
#
|
66
67
|
# The method will automatically setup all the associations, and create <tt>before_save</tt>
|
67
68
|
# and <tt>before_create</tt> filters for doing the stamping.
|
69
|
+
# By default, the deleter association and before filter are not defined unless you are using
|
70
|
+
# acts_as_paranoid or you set the :deleter_attribute or set the :deleter option to true.
|
68
71
|
def stampable(options = {})
|
72
|
+
compatability = Ddb::Userstamp.compatibility_mode
|
69
73
|
defaults = {
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
74
|
+
:stamper_class_name => :user,
|
75
|
+
:creator_attribute => (compatability ? :created_by : :creator_id),
|
76
|
+
:updater_attribute => (compatability ? :updated_by : :updater_id),
|
77
|
+
:deleter_attribute => (compatability ? :deleted_by : :deleter_id),
|
78
|
+
:deleter => !!(options.has_key?(:deleter_attribute) or defined?(Caboose::Acts::Paranoid))
|
79
|
+
}.merge(options)
|
75
80
|
|
76
81
|
self.stamper_class_name = defaults[:stamper_class_name].to_sym
|
77
82
|
self.creator_attribute = defaults[:creator_attribute].to_sym
|
@@ -79,18 +84,15 @@ module Ddb #:nodoc:
|
|
79
84
|
self.deleter_attribute = defaults[:deleter_attribute].to_sym
|
80
85
|
|
81
86
|
class_eval do
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
:foreign_key => self.updater_attribute
|
87
|
-
|
87
|
+
klass = stamper_class_name.to_s.singularize.camelize
|
88
|
+
belongs_to :creator, :class_name => klass, :foreign_key => creator_attribute
|
89
|
+
belongs_to :updater, :class_name => klass, :foreign_key => updater_attribute
|
90
|
+
|
88
91
|
before_save :set_updater_attribute
|
89
92
|
before_create :set_creator_attribute
|
90
|
-
|
91
|
-
if
|
92
|
-
belongs_to :deleter, :class_name =>
|
93
|
-
:foreign_key => self.deleter_attribute
|
93
|
+
|
94
|
+
if defaults[:deleter]
|
95
|
+
belongs_to :deleter, :class_name => klass, :foreign_key => deleter_attribute
|
94
96
|
before_destroy :set_deleter_attribute
|
95
97
|
end
|
96
98
|
end
|
@@ -107,6 +109,7 @@ module Ddb #:nodoc:
|
|
107
109
|
original_value = self.record_userstamp
|
108
110
|
self.record_userstamp = false
|
109
111
|
yield
|
112
|
+
ensure
|
110
113
|
self.record_userstamp = original_value
|
111
114
|
end
|
112
115
|
|
data/lib/userstamp.rb
CHANGED
@@ -2,6 +2,10 @@ require 'stamper'
|
|
2
2
|
require 'stampable'
|
3
3
|
require 'migration_helper'
|
4
4
|
|
5
|
+
module Userstamp
|
6
|
+
VERSION = File.read( File.join(File.dirname(__FILE__),'..','VERSION') ).strip
|
7
|
+
end
|
8
|
+
|
5
9
|
module Ddb
|
6
10
|
module Controller
|
7
11
|
# The Userstamp module, when included into a controller, adds a before filter
|
@@ -55,6 +55,10 @@
|
|
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
|
60
|
+
</a>
|
61
|
+
<br />
|
58
62
|
<a href="../../files/lib/migration_helper_rb.html">
|
59
63
|
lib/migration_helper.rb
|
60
64
|
</a>
|
@@ -62,10 +66,6 @@
|
|
62
66
|
<a href="../../files/lib/stampable_rb.html">
|
63
67
|
lib/stampable.rb
|
64
68
|
</a>
|
65
|
-
<br />
|
66
|
-
<a href="../../files/lib/stamper_rb.html">
|
67
|
-
lib/stamper.rb
|
68
|
-
</a>
|
69
69
|
<br />
|
70
70
|
</td>
|
71
71
|
</tr>
|
@@ -124,48 +124,50 @@ is the method to use. Here‘s an example:
|
|
124
124
|
:creator_attribute => :create_user,
|
125
125
|
:updater_attribute => :update_user,
|
126
126
|
:deleter_attribute => :delete_user
|
127
|
+
:deleter => true
|
127
128
|
end
|
128
129
|
</pre>
|
129
130
|
<p>
|
130
131
|
The method will automatically setup all the associations, and create
|
131
132
|
<tt>before_save</tt> and <tt>before_create</tt> filters for doing the
|
132
|
-
stamping.
|
133
|
+
stamping. By default, the deleter association and before filter are not
|
134
|
+
defined unless you are using acts_as_paranoid or you set the
|
135
|
+
:deleter_attribute or set the :deleter option to true.
|
133
136
|
</p>
|
134
137
|
<p><a class="source-toggle" href="#"
|
135
138
|
onclick="toggleCode('M000005-source');return false;">[Source]</a></p>
|
136
139
|
<div class="method-source-code" id="M000005-source">
|
137
140
|
<pre>
|
138
|
-
<span class="ruby-comment cmt"># File lib/stampable.rb, line
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
77: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">creator_attribute</span> = <span class="ruby-identifier">defaults</span>[<span class="ruby-identifier">:creator_attribute</span>].<span class="ruby-identifier">to_sym</span>
|
149
|
-
78: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">updater_attribute</span> = <span class="ruby-identifier">defaults</span>[<span class="ruby-identifier">:updater_attribute</span>].<span class="ruby-identifier">to_sym</span>
|
150
|
-
79: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">deleter_attribute</span> = <span class="ruby-identifier">defaults</span>[<span class="ruby-identifier">:deleter_attribute</span>].<span class="ruby-identifier">to_sym</span>
|
141
|
+
<span class="ruby-comment cmt"># File lib/stampable.rb, line 71</span>
|
142
|
+
71: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">stampable</span>(<span class="ruby-identifier">options</span> = {})
|
143
|
+
72: <span class="ruby-identifier">compatability</span> = <span class="ruby-constant">Ddb</span><span class="ruby-operator">::</span><span class="ruby-constant">Userstamp</span>.<span class="ruby-identifier">compatibility_mode</span>
|
144
|
+
73: <span class="ruby-identifier">defaults</span> = {
|
145
|
+
74: <span class="ruby-identifier">:stamper_class_name</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">:user</span>,
|
146
|
+
75: <span class="ruby-identifier">:creator_attribute</span> =<span class="ruby-operator">></span> (<span class="ruby-identifier">compatability</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>),
|
147
|
+
76: <span class="ruby-identifier">:updater_attribute</span> =<span class="ruby-operator">></span> (<span class="ruby-identifier">compatability</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>),
|
148
|
+
77: <span class="ruby-identifier">:deleter_attribute</span> =<span class="ruby-operator">></span> (<span class="ruby-identifier">compatability</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>),
|
149
|
+
78: <span class="ruby-identifier">:deleter</span> =<span class="ruby-operator">></span> <span class="ruby-operator">!</span><span class="ruby-operator">!</span>(<span class="ruby-identifier">options</span>.<span class="ruby-identifier">has_key?</span>(<span class="ruby-identifier">:deleter_attribute</span>) <span class="ruby-keyword kw">or</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>))
|
150
|
+
79: }.<span class="ruby-identifier">merge</span>(<span class="ruby-identifier">options</span>)
|
151
151
|
80:
|
152
|
-
81: <span class="ruby-identifier">
|
153
|
-
82:
|
154
|
-
83:
|
155
|
-
84:
|
156
|
-
85:
|
157
|
-
86:
|
158
|
-
87:
|
159
|
-
88: <span class="ruby-identifier">
|
160
|
-
89: <span class="ruby-identifier">
|
161
|
-
90:
|
162
|
-
91: <span class="ruby-
|
163
|
-
92:
|
164
|
-
93:
|
165
|
-
94:
|
166
|
-
95:
|
167
|
-
96:
|
168
|
-
97:
|
152
|
+
81: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">stamper_class_name</span> = <span class="ruby-identifier">defaults</span>[<span class="ruby-identifier">:stamper_class_name</span>].<span class="ruby-identifier">to_sym</span>
|
153
|
+
82: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">creator_attribute</span> = <span class="ruby-identifier">defaults</span>[<span class="ruby-identifier">:creator_attribute</span>].<span class="ruby-identifier">to_sym</span>
|
154
|
+
83: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">updater_attribute</span> = <span class="ruby-identifier">defaults</span>[<span class="ruby-identifier">:updater_attribute</span>].<span class="ruby-identifier">to_sym</span>
|
155
|
+
84: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">deleter_attribute</span> = <span class="ruby-identifier">defaults</span>[<span class="ruby-identifier">:deleter_attribute</span>].<span class="ruby-identifier">to_sym</span>
|
156
|
+
85:
|
157
|
+
86: <span class="ruby-identifier">class_eval</span> <span class="ruby-keyword kw">do</span>
|
158
|
+
87: <span class="ruby-identifier">klass</span> = <span class="ruby-identifier">stamper_class_name</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">singularize</span>.<span class="ruby-identifier">camelize</span>
|
159
|
+
88: <span class="ruby-identifier">belongs_to</span> <span class="ruby-identifier">:creator</span>, <span class="ruby-identifier">:class_name</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">klass</span>, <span class="ruby-identifier">:foreign_key</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">creator_attribute</span>
|
160
|
+
89: <span class="ruby-identifier">belongs_to</span> <span class="ruby-identifier">:updater</span>, <span class="ruby-identifier">:class_name</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">klass</span>, <span class="ruby-identifier">:foreign_key</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">updater_attribute</span>
|
161
|
+
90:
|
162
|
+
91: <span class="ruby-identifier">before_save</span> <span class="ruby-identifier">:set_updater_attribute</span>
|
163
|
+
92: <span class="ruby-identifier">before_create</span> <span class="ruby-identifier">:set_creator_attribute</span>
|
164
|
+
93:
|
165
|
+
94: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">defaults</span>[<span class="ruby-identifier">:deleter</span>]
|
166
|
+
95: <span class="ruby-identifier">belongs_to</span> <span class="ruby-identifier">:deleter</span>, <span class="ruby-identifier">:class_name</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">klass</span>, <span class="ruby-identifier">:foreign_key</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">deleter_attribute</span>
|
167
|
+
96: <span class="ruby-identifier">before_destroy</span> <span class="ruby-identifier">:set_deleter_attribute</span>
|
168
|
+
97: <span class="ruby-keyword kw">end</span>
|
169
|
+
98: <span class="ruby-keyword kw">end</span>
|
170
|
+
99: <span class="ruby-keyword kw">end</span>
|
169
171
|
</pre>
|
170
172
|
</div>
|
171
173
|
</div>
|
@@ -195,13 +197,14 @@ Temporarily allows you to turn stamping off. For example:
|
|
195
197
|
onclick="toggleCode('M000006-source');return false;">[Source]</a></p>
|
196
198
|
<div class="method-source-code" id="M000006-source">
|
197
199
|
<pre>
|
198
|
-
<span class="ruby-comment cmt"># File lib/stampable.rb, line
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
200
|
+
<span class="ruby-comment cmt"># File lib/stampable.rb, line 108</span>
|
201
|
+
108: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">without_stamps</span>
|
202
|
+
109: <span class="ruby-identifier">original_value</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">record_userstamp</span>
|
203
|
+
110: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">record_userstamp</span> = <span class="ruby-keyword kw">false</span>
|
204
|
+
111: <span class="ruby-keyword kw">yield</span>
|
205
|
+
112: <span class="ruby-keyword kw">ensure</span>
|
206
|
+
113: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">record_userstamp</span> = <span class="ruby-identifier">original_value</span>
|
207
|
+
114: <span class="ruby-keyword kw">end</span>
|
205
208
|
</pre>
|
206
209
|
</div>
|
207
210
|
</div>
|
@@ -151,7 +151,7 @@ for the current request.
|
|
151
151
|
<pre>
|
152
152
|
<span class="ruby-comment cmt"># File lib/stamper.rb, line 30</span>
|
153
153
|
30: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">stamper</span>
|
154
|
-
31: <span class="ruby-
|
154
|
+
31: <span class="ruby-constant">Thread</span>.<span class="ruby-identifier">current</span>[<span class="ruby-node">"#{self.to_s.downcase}_#{self.object_id}_stamper"</span>]
|
155
155
|
32: <span class="ruby-keyword kw">end</span>
|
156
156
|
</pre>
|
157
157
|
</div>
|
@@ -0,0 +1,118 @@
|
|
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: Userstamp</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">Userstamp</td>
|
54
|
+
</tr>
|
55
|
+
<tr class="top-aligned-row">
|
56
|
+
<td><strong>In:</strong></td>
|
57
|
+
<td>
|
58
|
+
<a href="../files/lib/userstamp_rb.html">
|
59
|
+
lib/userstamp.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
|
+
|
80
|
+
</div>
|
81
|
+
|
82
|
+
|
83
|
+
<!-- if includes -->
|
84
|
+
|
85
|
+
<div id="section">
|
86
|
+
|
87
|
+
|
88
|
+
<div id="constants-list">
|
89
|
+
<h3 class="section-bar">Constants</h3>
|
90
|
+
|
91
|
+
<div class="name-list">
|
92
|
+
<table summary="Constants">
|
93
|
+
<tr class="top-aligned-row context-row">
|
94
|
+
<td class="context-item-name">VERSION</td>
|
95
|
+
<td>=</td>
|
96
|
+
<td class="context-item-value">File.read( File.join(File.dirname(__FILE__),'..','VERSION') ).strip</td>
|
97
|
+
</tr>
|
98
|
+
</table>
|
99
|
+
</div>
|
100
|
+
</div>
|
101
|
+
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
<!-- if method_list -->
|
108
|
+
|
109
|
+
|
110
|
+
</div>
|
111
|
+
|
112
|
+
|
113
|
+
<div id="validator-badges">
|
114
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
115
|
+
</div>
|
116
|
+
|
117
|
+
</body>
|
118
|
+
</html>
|