public
Fork of mmower/simply_versioned
Description: A simple, non-invasive, approach to versioning ActiveRecord models
Homepage: http://softwareheretics.com/plugins/simply_versioned
Clone URL: git://github.com/bmizerany/simply_versioned.git
Tidying up docs for 1.0
mmower (author)
Mon Jan 28 13:36:58 -0800 2008
commit  5905d0caf167b904f41be0be2fed74a1897f1e2c
tree    b3c73c5e5fa075515a6efb7766f2896f1168af7e
parent  3d56171519d1c940f8a0bae1da99bc74ee3e1efa
...
 
 
 
 
 
 
1
2
3
...
1
2
3
4
5
6
7
8
9
0
@@ -1,3 +1,9 @@
0
+1.0.0 - 28-01-2008
0
+
0
+A number of doc fixes.
0
+A couple of small fixes.
0
+We moved to GitHub!
0
+
0
 0.9.3  - 28-01-2008
0
 
0
 Fixed #version_number to versioned instances as a shortcut
0
...
1
2
3
4
 
5
6
7
8
9
10
 
11
12
13
14
15
16
17
 
 
18
19
20
...
123
124
125
 
126
127
128
...
1
2
3
 
4
5
6
7
8
9
 
10
11
12
13
14
15
 
 
16
17
18
19
20
...
123
124
125
126
127
128
129
0
@@ -1,20 +1,20 @@
0
 SimplyVersioned
0
 ===============
0
 
0
-Release: 0.9.3
0
+Release: 1.0.0
0
 Date:      28-01-2008
0
 Author:    Matt Mower <self@mattmower.com>
0
 
0
 SimplyVersioned is a simple, non-invasive, approach to versioning ActiveRecord models.
0
 
0
-SimplyVersioned does not require any structural change to the models to be versioned and requires only one versions table to be created (a migration generator is supplied with the plugin) regardless of the number of models being versioned.
0
+SimplyVersioned does not require any structural change to the models to be versioned and requires only one versions table to be created (a migration generator is supplied with the plugin) for the application, regardless of the number of models being versioned.
0
 
0
 The plugin introduces a 'Version' ActiveRecord model (that reflects changes to model attributes) to which versioned models are polymorphically associated. Version records store the model information as a YAML hash.
0
   
0
 SimplyVersioned meets a simple need for model versioning. If your needs are more complex maybe try Rick Olsen's acts_as_versioned (http://svn.techno-weenie.net/projects/plugins/acts_as_versioned/).
0
   
0
-SimplyVersioned is (so far) actively tested with Rails 2.0.2 and Ruby 1.8.6p111 on MacOSX.
0
-
0
+SimplyVersioned is (so far) actively tested with Rails 2.0.2 and Ruby 1.8.6
0
+
0
 Usage
0
 =====
0
 
0
@@ -123,6 +123,7 @@ Usage
0
   
0
 Thanks to:
0
 
0
+ Chris Wanstrath (http://ozmm.org/) for useful feedback and GitHub
0
   Josh Susser (http://blog.hasmanythrough.com/) for useful suggestions and feedback
0
   Rick Olson (http://techno-weenie.net/) for all the many plugins whose code i've read
0
   
...
1
 
2
3
4
...
24
25
26
27
28
29
 
 
 
30
31
32
33
34
35
 
 
36
37
38
...
81
82
83
84
 
85
86
87
...
96
97
98
99
 
100
101
102
...
104
105
106
 
 
 
 
 
 
107
108
109
...
114
115
116
 
117
118
 
119
120
 
121
122
123
124
 
125
126
 
127
128
129
...
132
133
134
135
 
136
137
138
...
143
144
145
 
146
147
148
 
149
150
151
...
184
185
186
187
 
188
189
190
...
 
1
2
3
4
...
24
25
26
 
 
 
27
28
29
30
 
 
 
 
 
31
32
33
34
35
...
78
79
80
 
81
82
83
84
...
93
94
95
 
96
97
98
99
...
101
102
103
104
105
106
107
108
109
110
111
112
...
117
118
119
120
121
 
122
123
124
125
126
127
128
129
130
131
 
132
133
134
135
...
138
139
140
 
141
142
143
144
...
149
150
151
152
153
154
 
155
156
157
158
...
191
192
193
 
194
195
196
197
0
@@ -1,4 +1,4 @@
0
-# SimplyVersioned 0.9.3
0
+# SimplyVersioned 1.0.0
0
 #
0
 # Simple ActiveRecord versioning
0
 # Copyright (c) 2007,2008 Matt Mower <self@mattmower.com>
0
@@ -24,15 +24,12 @@ module SoftwareHeretics
0
         # the +versions+ association.
0
         #
0
         # Options:
0
- # +limit+ - specifies the number of old versions to keep (default = nil, never delete old versions)
0
- # +automatic+ - controls whether versions are created automatically (default = true, save versions)
0
- # +exclude+ - specify columns that will not be saved (default = [], save all columns)
0
+ # * +limit+ - specifies the number of old versions to keep (default = nil, never delete old versions)
0
+ # * +automatic+ - controls whether versions are created automatically (default = true, save versions)
0
+ # * +exclude+ - specify columns that will not be saved (default = [], save all columns)
0
         #
0
- # To save the record without creating a version either set +versioning_enabled+ to false
0
- # on the model before calling save or, alternatively, use +without_versioning+ and save
0
- # the model from its block.
0
- #
0
-
0
+ # To save a model without creating a new version it is recommended to use with +with_versioning+
0
+ # method rather than changing +versioning_enabled+ for the entire model.
0
         def simply_versioned( options = {} )
0
           bad_keys = options.keys - [:keep,:automatic,:exclude]
0
           raise SimplyVersioned::BadOptions.new( bad_keys ) unless bad_keys.empty?
0
@@ -81,7 +78,7 @@ module SoftwareHeretics
0
         # Pass either a Version instance or a version number.
0
         #
0
         # options:
0
- # +except+ specify a list of attributes that are not restored (default: created_at, updated_at)
0
+ # * +except+ specify a list of attributes that are not restored (default: created_at, updated_at)
0
         #
0
         def revert_to_version( version, options = {} )
0
           options.reverse_merge!({
0
@@ -96,7 +93,7 @@ module SoftwareHeretics
0
           
0
           raise "Invalid version (#{version.inspect}) specified!" unless version
0
           
0
- options[:except] = options[:except].map( &:to_s )
0
+ options[:except] = Array( options[:except] ).map( &:to_s )
0
           
0
           self.update_attributes( YAML::load( version.yaml ).except( *options[:except] ) )
0
         end
0
@@ -104,6 +101,12 @@ module SoftwareHeretics
0
         # Invoke the supplied block passing the receiver as the sole block argument with
0
         # versioning enabled or disabled depending upon the value of the +enabled+ parameter
0
         # for the duration of the block.
0
+ #
0
+ # Example:
0
+ #
0
+ # <tt>
0
+ # thing.with_versioning( params[:should_version] == "yes" ) { save! }
0
+ # </tt>
0
         def with_versioning( enabled, &block )
0
           versioning_was_enabled = self.versioning_enabled?
0
           self.versioning_enabled = enabled
0
@@ -114,16 +117,19 @@ module SoftwareHeretics
0
           end
0
         end
0
         
0
+ # Return +true+ if the model has not been versioned yet.
0
         def unversioned?
0
- self.versions.nil? || self.versions.size == 0
0
+ self.versions.nil? || self.versions.empty?
0
         end
0
         
0
+ # Return +true+ if the model has been versioned.
0
         def versioned?
0
           !unversioned?
0
         end
0
         
0
+ # Returns 0 for unversioned models, 1 for newly created models, and so on.
0
         def version_number
0
- if self.versions.empty?
0
+ if self.unversioned?
0
             0
0
           else
0
             self.versions.current.number
0
@@ -132,7 +138,7 @@ module SoftwareHeretics
0
         
0
         protected
0
         
0
- def simply_versioned_create_version
0
+ def simply_versioned_create_version #:nodoc:
0
           if self.versioning_enabled?
0
             if self.versions.create( :yaml => self.attributes.except( *simply_versioned_excluded_columns ).to_yaml )
0
               self.versions.clean_old_versions( simply_versioned_keep_limit.to_i ) if simply_versioned_keep_limit
0
@@ -143,9 +149,10 @@ module SoftwareHeretics
0
         
0
       end
0
 
0
+ # Methods added to the +versions+ collection of a versioned model.
0
       module VersionsProxyMethods
0
         
0
- # Get the Version instance corresponding to this models for the specified version number.
0
+ # Get the +Version+ instance corresponding to this specified version number for this model instance.
0
         def get_version( number )
0
           find_by_number( number )
0
         end
0
@@ -184,7 +191,7 @@ module SoftwareHeretics
0
         alias_method :previous, :previous_version
0
       end
0
 
0
- def self.included( receiver )
0
+ def self.included( receiver ) #:nodoc:
0
         receiver.extend ClassMethods
0
         receiver.send :include, InstanceMethods
0
       end
...
1
 
2
3
4
...
36
37
38
39
 
40
41
42
...
 
1
2
3
4
...
36
37
38
 
39
40
41
42
0
@@ -1,4 +1,4 @@
0
-# SimplyVersioned 0.9.3
0
+# SimplyVersioned 1.0.0
0
 #
0
 # Simple ActiveRecord versioning
0
 # Copyright (c) 2007,2008 Matt Mower <self@mattmower.com>
0
@@ -36,7 +36,7 @@ class Version < ActiveRecord::Base #:nodoc:
0
   end
0
 
0
 protected
0
- def before_create
0
+ def before_create #:nodoc:
0
     if versionable.unversioned?
0
       self.number = 1
0
     else
...
125
126
127
128
129
130
131
132
 
 
 
 
 
133
134
135
...
125
126
127
 
 
 
 
 
128
129
130
131
132
133
134
135
0
@@ -125,11 +125,11 @@ Class <a href="SimplyVersioned/BadOptions.html" class="link">SoftwareHeretics::A
0
             onclick="toggleCode('M000001-source');return false;">[Source]</a></p>
0
           <div class="method-source-code" id="M000001-source">
0
 <pre>
0
- <span class="ruby-comment cmt"># File lib/simply_versioned.rb, line 187</span>
0
-187: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">included</span>( <span class="ruby-identifier">receiver</span> )
0
-188: <span class="ruby-identifier">receiver</span>.<span class="ruby-identifier">extend</span> <span class="ruby-constant">ClassMethods</span>
0
-189: <span class="ruby-identifier">receiver</span>.<span class="ruby-identifier">send</span> <span class="ruby-identifier">:include</span>, <span class="ruby-constant">InstanceMethods</span>
0
-190: <span class="ruby-keyword kw">end</span>
0
+ <span class="ruby-comment cmt"># File lib/simply_versioned.rb, line 190</span>
0
+190: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">included</span>( <span class="ruby-identifier">receiver</span> )
0
+191: <span class="ruby-identifier">receiver</span>.<span class="ruby-identifier">extend</span> <span class="ruby-constant">ClassMethods</span>
0
+192: <span class="ruby-identifier">receiver</span>.<span class="ruby-identifier">send</span> <span class="ruby-identifier">:include</span>, <span class="ruby-constant">InstanceMethods</span>
0
+193: <span class="ruby-keyword kw">end</span>
0
 </pre>
0
           </div>
0
         </div>
...
121
122
123
124
125
126
127
128
 
129
 
 
 
 
 
 
 
 
 
 
 
 
 
 
130
131
132
133
134
 
 
 
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
154
155
156
 
 
157
158
159
 
 
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
 
 
 
 
 
 
 
 
 
 
 
 
 
 
178
179
180
...
194
195
196
197
198
199
200
 
 
 
 
201
202
203
...
217
218
219
220
221
222
223
224
225
226
227
 
 
 
 
 
 
 
 
228
229
230
...
121
122
123
 
 
 
 
 
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
 
 
 
 
141
142
143
144
145
146
147
148
 
 
 
 
 
 
 
 
 
 
 
 
 
 
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
 
 
167
168
169
 
 
170
171
172
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
...
203
204
205
 
 
 
 
206
207
208
209
210
211
212
...
226
227
228
 
 
 
 
 
 
 
 
229
230
231
232
233
234
235
236
237
238
239
0
@@ -121,60 +121,69 @@ create a series of associated Version instances that can be accessed via
0
 the <tt>versions</tt> association.
0
 </p>
0
 <p>
0
-Options: <tt>limit</tt> - specifies the number of old versions to keep
0
-(default = nil, never delete old versions) <tt>automatic</tt> - controls
0
-whether versions are created automatically (default = true, save versions)
0
-<tt>exclude</tt> - specify columns that will not be saved (default = [],
0
-save all columns)
0
+Options:
0
 </p>
0
+<ul>
0
+<li><tt>limit</tt> - specifies the number of old versions to keep (default =
0
+nil, never delete old versions)
0
+
0
+</li>
0
+<li><tt>automatic</tt> - controls whether versions are created automatically
0
+(default = true, save versions)
0
+
0
+</li>
0
+<li><tt>exclude</tt> - specify columns that will not be saved (default = [],
0
+save all columns)
0
+
0
+</li>
0
+</ul>
0
 <p>
0
-To save the record without creating a version either set
0
-<tt>versioning_enabled</tt> to false on the model before calling save or,
0
-alternatively, use <tt>without_versioning</tt> and save the model from its
0
-block.
0
+To save a model without creating a new version it is recommended to use
0
+with <tt>with_versioning</tt> method rather than changing
0
+<tt>versioning_enabled</tt> for the entire model.
0
 </p>
0
           <p><a class="source-toggle" href="#"
0
             onclick="toggleCode('M000014-source');return false;">[Source]</a></p>
0
           <div class="method-source-code" id="M000014-source">
0
 <pre>
0
- <span class="ruby-comment cmt"># File lib/simply_versioned.rb, line 36</span>
0
-36: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">simply_versioned</span>( <span class="ruby-identifier">options</span> = {} )
0
-37: <span class="ruby-identifier">bad_keys</span> = <span class="ruby-identifier">options</span>.<span class="ruby-identifier">keys</span> <span class="ruby-operator">-</span> [<span class="ruby-identifier">:keep</span>,<span class="ruby-identifier">:automatic</span>,<span class="ruby-identifier">:exclude</span>]
0
-38: <span class="ruby-identifier">raise</span> <span class="ruby-constant">SimplyVersioned</span><span class="ruby-operator">::</span><span class="ruby-constant">BadOptions</span>.<span class="ruby-identifier">new</span>( <span class="ruby-identifier">bad_keys</span> ) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">bad_keys</span>.<span class="ruby-identifier">empty?</span>
0
-39:
0
-40: <span class="ruby-identifier">options</span>.<span class="ruby-identifier">reverse_merge!</span>( {
0
-41: <span class="ruby-identifier">:keep</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">nil</span>,
0
-42: <span class="ruby-identifier">:automatic</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">true</span>,
0
-43: <span class="ruby-identifier">:exclude</span> =<span class="ruby-operator">&gt;</span> []
0
-44: })
0
-45:
0
-46: <span class="ruby-identifier">has_many</span> <span class="ruby-identifier">:versions</span>, <span class="ruby-identifier">:order</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">'number DESC'</span>, <span class="ruby-identifier">:as</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">:versionable</span>, <span class="ruby-identifier">:dependent</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">:destroy</span>, <span class="ruby-identifier">:extend</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-constant">VersionsProxyMethods</span>
0
-47:
0
-48: <span class="ruby-identifier">after_save</span> <span class="ruby-identifier">:simply_versioned_create_version</span>
0
+ <span class="ruby-comment cmt"># File lib/simply_versioned.rb, line 33</span>
0
+33: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">simply_versioned</span>( <span class="ruby-identifier">options</span> = {} )
0
+34: <span class="ruby-identifier">bad_keys</span> = <span class="ruby-identifier">options</span>.<span class="ruby-identifier">keys</span> <span class="ruby-operator">-</span> [<span class="ruby-identifier">:keep</span>,<span class="ruby-identifier">:automatic</span>,<span class="ruby-identifier">:exclude</span>]
0
+35: <span class="ruby-identifier">raise</span> <span class="ruby-constant">SimplyVersioned</span><span class="ruby-operator">::</span><span class="ruby-constant">BadOptions</span>.<span class="ruby-identifier">new</span>( <span class="ruby-identifier">bad_keys</span> ) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">bad_keys</span>.<span class="ruby-identifier">empty?</span>
0
+36:
0
+37: <span class="ruby-identifier">options</span>.<span class="ruby-identifier">reverse_merge!</span>( {
0
+38: <span class="ruby-identifier">:keep</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">nil</span>,
0
+39: <span class="ruby-identifier">:automatic</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">true</span>,
0
+40: <span class="ruby-identifier">:exclude</span> =<span class="ruby-operator">&gt;</span> []
0
+41: })
0
+42:
0
+43: <span class="ruby-identifier">has_many</span> <span class="ruby-identifier">:versions</span>, <span class="ruby-identifier">:order</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">'number DESC'</span>, <span class="ruby-identifier">:as</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">:versionable</span>, <span class="ruby-identifier">:dependent</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">:destroy</span>, <span class="ruby-identifier">:extend</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-constant">VersionsProxyMethods</span>
0
+44:
0
+45: <span class="ruby-identifier">after_save</span> <span class="ruby-identifier">:simply_versioned_create_version</span>
0
+46:
0
+47: <span class="ruby-identifier">cattr_accessor</span> <span class="ruby-identifier">:simply_versioned_keep_limit</span>
0
+48: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">simply_versioned_keep_limit</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:keep</span>]
0
 49:
0
-50: <span class="ruby-identifier">cattr_accessor</span> <span class="ruby-identifier">:simply_versioned_keep_limit</span>
0
-51: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">simply_versioned_keep_limit</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:keep</span>]
0
+50: <span class="ruby-identifier">cattr_accessor</span> <span class="ruby-identifier">:simply_versioned_save_by_default</span>
0
+51: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">simply_versioned_save_by_default</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:automatic</span>]
0
 52:
0
-53: <span class="ruby-identifier">cattr_accessor</span> <span class="ruby-identifier">:simply_versioned_save_by_default</span>
0
-54: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">simply_versioned_save_by_default</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:automatic</span>]
0
+53: <span class="ruby-identifier">cattr_accessor</span> <span class="ruby-identifier">:simply_versioned_excluded_columns</span>
0
+54: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">simply_versioned_excluded_columns</span> = <span class="ruby-constant">Array</span>( <span class="ruby-identifier">options</span>[ <span class="ruby-identifier">:exclude</span> ] ).<span class="ruby-identifier">map</span>( <span class="ruby-operator">&amp;</span><span class="ruby-identifier">:to_s</span> )
0
 55:
0
-56: <span class="ruby-identifier">cattr_accessor</span> <span class="ruby-identifier">:simply_versioned_excluded_columns</span>
0
-57: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">simply_versioned_excluded_columns</span> = <span class="ruby-constant">Array</span>( <span class="ruby-identifier">options</span>[ <span class="ruby-identifier">:exclude</span> ] ).<span class="ruby-identifier">map</span>( <span class="ruby-operator">&amp;</span><span class="ruby-identifier">:to_s</span> )
0
-58:
0
-59: <span class="ruby-identifier">class_eval</span> <span class="ruby-keyword kw">do</span>
0
-60: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">versioning_enabled=</span>( <span class="ruby-identifier">enabled</span> )
0
-61: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">instance_variable_set</span>( <span class="ruby-identifier">:@simply_versioned_enabled</span>, <span class="ruby-identifier">enabled</span> )
0
-62: <span class="ruby-keyword kw">end</span>
0
-63:
0
-64: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">versioning_enabled?</span>
0
-65: <span class="ruby-identifier">enabled</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">instance_variable_get</span>( <span class="ruby-identifier">:@simply_versioned_enabled</span> )
0
-66: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">enabled</span>.<span class="ruby-identifier">nil?</span>
0
-67: <span class="ruby-identifier">enabled</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">instance_variable_set</span>( <span class="ruby-identifier">:@simply_versioned_enabled</span>, <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">simply_versioned_save_by_default</span> )
0
-68: <span class="ruby-keyword kw">end</span>
0
-69: <span class="ruby-identifier">enabled</span>
0
-70: <span class="ruby-keyword kw">end</span>
0
-71: <span class="ruby-keyword kw">end</span>
0
-72: <span class="ruby-keyword kw">end</span>
0
+56: <span class="ruby-identifier">class_eval</span> <span class="ruby-keyword kw">do</span>
0
+57: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">versioning_enabled=</span>( <span class="ruby-identifier">enabled</span> )
0
+58: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">instance_variable_set</span>( <span class="ruby-identifier">:@simply_versioned_enabled</span>, <span class="ruby-identifier">enabled</span> )
0
+59: <span class="ruby-keyword kw">end</span>
0
+60:
0
+61: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">versioning_enabled?</span>
0
+62: <span class="ruby-identifier">enabled</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">instance_variable_get</span>( <span class="ruby-identifier">:@simply_versioned_enabled</span> )
0
+63: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">enabled</span>.<span class="ruby-identifier">nil?</span>
0
+64: <span class="ruby-identifier">enabled</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">instance_variable_set</span>( <span class="ruby-identifier">:@simply_versioned_enabled</span>, <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">simply_versioned_save_by_default</span> )
0
+65: <span class="ruby-keyword kw">end</span>
0
+66: <span class="ruby-identifier">enabled</span>
0
+67: <span class="ruby-keyword kw">end</span>
0
+68: <span class="ruby-keyword kw">end</span>
0
+69: <span class="ruby-keyword kw">end</span>
0
 </pre>
0
           </div>
0
         </div>
0
@@ -194,10 +203,10 @@ block.
0
             onclick="toggleCode('M000015-source');return false;">[Source]</a></p>
0
           <div class="method-source-code" id="M000015-source">
0
 <pre>
0
- <span class="ruby-comment cmt"># File lib/simply_versioned.rb, line 60</span>
0
-60: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">versioning_enabled=</span>( <span class="ruby-identifier">enabled</span> )
0
-61: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">instance_variable_set</span>( <span class="ruby-identifier">:@simply_versioned_enabled</span>, <span class="ruby-identifier">enabled</span> )
0
-62: <span class="ruby-keyword kw">end</span>
0
+ <span class="ruby-comment cmt"># File lib/simply_versioned.rb, line 57</span>
0
+57: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">versioning_enabled=</span>( <span class="ruby-identifier">enabled</span> )
0
+58: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">instance_variable_set</span>( <span class="ruby-identifier">:@simply_versioned_enabled</span>, <span class="ruby-identifier">enabled</span> )
0
+59: <span class="ruby-keyword kw">end</span>
0
 </pre>
0
           </div>
0
         </div>
0
@@ -217,14 +226,14 @@ block.
0
             onclick="toggleCode('M000016-source');return false;">[Source]</a></p>
0
           <div class="method-source-code" id="M000016-source">
0
 <pre>
0
- <span class="ruby-comment cmt"># File lib/simply_versioned.rb, line 64</span>
0
-64: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">versioning_enabled?</span>
0
-65: <span class="ruby-identifier">enabled</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">instance_variable_get</span>( <span class="ruby-identifier">:@simply_versioned_enabled</span> )
0
-66: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">enabled</span>.<span class="ruby-identifier">nil?</span>
0
-67: <span class="ruby-identifier">enabled</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">instance_variable_set</span>( <span class="ruby-identifier">:@simply_versioned_enabled</span>, <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">simply_versioned_save_by_default</span> )
0
-68: <span class="ruby-keyword kw">end</span>
0
-69: <span class="ruby-identifier">enabled</span>
0
-70: <span class="ruby-keyword kw">end</span>
0
+ <span class="ruby-comment cmt"># File lib/simply_versioned.rb, line 61</span>
0
+61: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">versioning_enabled?</span>
0
+62: <span class="ruby-identifier">enabled</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">instance_variable_get</span>( <span class="ruby-identifier">:@simply_versioned_enabled</span> )
0
+63: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">enabled</span>.<span class="ruby-identifier">nil?</span>
0
+64: <span class="ruby-identifier">enabled</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">instance_variable_set</span>( <span class="ruby-identifier">:@simply_versioned_enabled</span>, <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">simply_versioned_save_by_default</span> )
0
+65: <span class="ruby-keyword kw">end</span>
0
+66: <span class="ruby-identifier">enabled</span>
0
+67: <span class="ruby-keyword kw">end</span>
0
 </pre>
0
           </div>
0
         </div>
...
132
133
134
135
136
 
137
 
 
 
 
 
 
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
160
161
162
...
176
177
178
179
180
181
182
 
 
 
 
183
184
185
...
199
200
201
202
203
204
205
206
207
208
209
 
 
 
 
 
 
 
 
210
211
212
...
226
227
228
229
230
231
232
 
 
 
 
233
234
235
...
250
251
252
 
 
 
 
 
 
 
253
254
255
256
257
258
259
260
261
262
263
264
265
266
 
 
 
 
 
 
 
 
 
 
267
268
269
...
285
286
287
288
289
290
291
292
293
294
295
296
 
 
 
 
 
 
 
 
 
297
298
299
...
132
133
134
 
 
135
136
137
138
139
140
141
142
143
144
145
146
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
...
181
182
183
 
 
 
 
184
185
186
187
188
189
190
...
204
205
206
 
 
 
 
 
 
 
 
207
208
209
210
211
212
213
214
215
216
217
...
231
232
233
 
 
 
 
234
235
236
237
238
239
240
...
255
256
257
258
259
260
261
262
263
264
265
266
267
268
 
 
 
 
 
 
 
 
 
 
269
270
271
272
273
274
275
276
277
278
279
280
281
...
297
298
299
 
 
 
 
 
 
 
 
 
300
301
302
303
304
305
306
307
308
309
310
311
0
@@ -132,31 +132,36 @@ version.
0
 Pass either a Version instance or a version number.
0
 </p>
0
 <p>
0
-options: <tt>except</tt> specify a list of attributes that are not restored
0
-(default: created_at, updated_at)
0
+options:
0
 </p>
0
+<ul>
0
+<li><tt>except</tt> specify a list of attributes that are not restored
0
+(default: created_at, updated_at)
0
+
0
+</li>
0
+</ul>
0
           <p><a class="source-toggle" href="#"
0
             onclick="toggleCode('M000017-source');return false;">[Source]</a></p>
0
           <div class="method-source-code" id="M000017-source">
0
 <pre>
0
- <span class="ruby-comment cmt"># File lib/simply_versioned.rb, line 86</span>
0
- 86: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">revert_to_version</span>( <span class="ruby-identifier">version</span>, <span class="ruby-identifier">options</span> = {} )
0
- 87: <span class="ruby-identifier">options</span>.<span class="ruby-identifier">reverse_merge!</span>({
0
- 88: <span class="ruby-identifier">:except</span> =<span class="ruby-operator">&gt;</span> [<span class="ruby-identifier">:created_at</span>,<span class="ruby-identifier">:updated_at</span>]
0
- 89: })
0
- 90:
0
- 91: <span class="ruby-identifier">version</span> = <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">version</span>.<span class="ruby-identifier">kind_of?</span>( <span class="ruby-constant">Version</span> )
0
- 92: <span class="ruby-identifier">version</span>
0
- 93: <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">version</span>.<span class="ruby-identifier">kind_of?</span>( <span class="ruby-constant">Fixnum</span> )
0
- 94: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">versions</span>.<span class="ruby-identifier">find_by_number</span>( <span class="ruby-identifier">version</span> )
0
- 95: <span class="ruby-keyword kw">end</span>
0
- 96:
0
- 97: <span class="ruby-identifier">raise</span> <span class="ruby-node">&quot;Invalid version (#{version.inspect}) specified!&quot;</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">version</span>
0
- 98:
0
- 99: <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:except</span>] = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:except</span>].<span class="ruby-identifier">map</span>( <span class="ruby-operator">&amp;</span><span class="ruby-identifier">:to_s</span> )
0
-100:
0
-101: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">update_attributes</span>( <span class="ruby-constant">YAML</span><span class="ruby-operator">::</span><span class="ruby-identifier">load</span>( <span class="ruby-identifier">version</span>.<span class="ruby-identifier">yaml</span> ).<span class="ruby-identifier">except</span>( <span class="ruby-operator">*</span><span class="ruby-identifier">options</span>[<span class="ruby-identifier">:except</span>] ) )
0
-102: <span class="ruby-keyword kw">end</span>
0
+ <span class="ruby-comment cmt"># File lib/simply_versioned.rb, line 83</span>
0
+83: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">revert_to_version</span>( <span class="ruby-identifier">version</span>, <span class="ruby-identifier">options</span> = {} )
0
+84: <span class="ruby-identifier">options</span>.<span class="ruby-identifier">reverse_merge!</span>({
0
+85: <span class="ruby-identifier">:except</span> =<span class="ruby-operator">&gt;</span> [<span class="ruby-identifier">:created_at</span>,<span class="ruby-identifier">:updated_at</span>]
0
+86: })
0
+87:
0
+88: <span class="ruby-identifier">version</span> = <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">version</span>.<span class="ruby-identifier">kind_of?</span>( <span class="ruby-constant">Version</span> )
0
+89: <span class="ruby-identifier">version</span>
0
+90: <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">version</span>.<span class="ruby-identifier">kind_of?</span>( <span class="ruby-constant">Fixnum</span> )
0
+91: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">versions</span>.<span class="ruby-identifier">find_by_number</span>( <span class="ruby-identifier">version</span> )
0
+92: <span class="ruby-keyword kw">end</span>
0
+93:
0
+94: <span class="ruby-identifier">raise</span> <span class="ruby-node">&quot;Invalid version (#{version.inspect}) specified!&quot;</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">version</span>
0
+95:
0
+96: <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:except</span>] = <span class="ruby-constant">Array</span>( <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:except</span>] ).<span class="ruby-identifier">map</span>( <span class="ruby-operator">&amp;</span><span class="ruby-identifier">:to_s</span> )
0
+97:
0
+98: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">update_attributes</span>( <span class="ruby-constant">YAML</span><span class="ruby-operator">::</span><span class="ruby-identifier">load</span>( <span class="ruby-identifier">version</span>.<span class="ruby-identifier">yaml</span> ).<span class="ruby-identifier">except</span>( <span class="ruby-operator">*</span><span class="ruby-identifier">options</span>[<span class="ruby-identifier">:except</span>] ) )
0
+99: <span class="ruby-keyword kw">end</span>
0
 </pre>
0
           </div>
0
         </div>
0
@@ -176,10 +181,10 @@ options: <tt>except</tt> specify a list of attributes that are not restored
0
             onclick="toggleCode('M000019-source');return false;">[Source]</a></p>
0
           <div class="method-source-code" id="M000019-source">
0
 <pre>
0
- <span class="ruby-comment cmt"># File lib/simply_versioned.rb, line 117</span>
0
-117: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">unversioned?</span>
0
-118: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">versions</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">||</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">versions</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span>
0
-119: <span class="ruby-keyword kw">end</span>
0
+ <span class="ruby-comment cmt"># File lib/simply_versioned.rb, line 120</span>
0
+120: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">unversioned?</span>
0
+121: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">versions</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">||</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">versions</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span>
0
+122: <span class="ruby-keyword kw">end</span>
0
 </pre>
0
           </div>
0
         </div>
0
@@ -199,14 +204,14 @@ options: <tt>except</tt> specify a list of attributes that are not restored
0
             onclick="toggleCode('M000021-source');return false;">[Source]</a></p>
0
           <div class="method-source-code" id="M000021-source">
0
 <pre>
0
- <span class="ruby-comment cmt"># File lib/simply_versioned.rb, line 125</span>
0
-125: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">version_number</span>
0
-126: <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">versions</span>.<span class="ruby-identifier">empty?</span>
0
-127: <span class="ruby-value">0</span>
0
-128: <span class="ruby-keyword kw">else</span>
0
-129: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">versions</span>.<span class="ruby-identifier">current</span>.<span class="ruby-identifier">number</span>
0
-130: <span class="ruby-keyword kw">end</span>
0
-131: <span class="ruby-keyword kw">end</span>
0
+ <span class="ruby-comment cmt"># File lib/simply_versioned.rb, line 128</span>
0
+128: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">version_number</span>
0
+129: <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">versions</span>.<span class="ruby-identifier">empty?</span>
0
+130: <span class="ruby-value">0</span>
0
+131: <span class="ruby-keyword kw">else</span>
0
+132: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">versions</span>.<span class="ruby-identifier">current</span>.<span class="ruby-identifier">number</span>
0
+133: <span class="ruby-keyword kw">end</span>
0
+134: <span class="ruby-keyword kw">end</span>
0
 </pre>
0
           </div>
0
         </div>
0
@@ -226,10 +231,10 @@ options: <tt>except</tt> specify a list of attributes that are not restored
0
             onclick="toggleCode('M000020-source');return false;">[Source]</a></p>
0
           <div class="method-source-code" id="M000020-source">
0
 <pre>
0
- <span class="ruby-comment cmt"># File lib/simply_versioned.rb, line 121</span>
0
-121: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier