0
@@ -121,60 +121,69 @@ create a series of associated Version instances that can be accessed via
0
the <tt>versions</tt> association.
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
+<li><tt>limit</tt> - specifies the number of old versions to keep (default =
0
+nil, never delete old versions)
0
+<li><tt>automatic</tt> - controls whether versions are created automatically
0
+(default = true, save versions)
0
+<li><tt>exclude</tt> - specify columns that will not be saved (default = [],
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
+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><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
- <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
-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">></span> <span class="ruby-keyword kw">nil</span>,
0
-42: <span class="ruby-identifier">:automatic</span> =<span class="ruby-operator">></span> <span class="ruby-keyword kw">true</span>,
0
-43: <span class="ruby-identifier">:exclude</span> =<span class="ruby-operator">></span> []
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">></span> <span class="ruby-value str">'number DESC'</span>, <span class="ruby-identifier">:as</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">:versionable</span>, <span class="ruby-identifier">:dependent</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">:destroy</span>, <span class="ruby-identifier">:extend</span> =<span class="ruby-operator">></span> <span class="ruby-constant">VersionsProxyMethods</span>
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
+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">></span> <span class="ruby-keyword kw">nil</span>,
0
+39: <span class="ruby-identifier">:automatic</span> =<span class="ruby-operator">></span> <span class="ruby-keyword kw">true</span>,
0
+40: <span class="ruby-identifier">:exclude</span> =<span class="ruby-operator">></span> []
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">></span> <span class="ruby-value str">'number DESC'</span>, <span class="ruby-identifier">:as</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">:versionable</span>, <span class="ruby-identifier">:dependent</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">:destroy</span>, <span class="ruby-identifier">:extend</span> =<span class="ruby-operator">></span> <span class="ruby-constant">VersionsProxyMethods</span>
0
+45: <span class="ruby-identifier">after_save</span> <span class="ruby-identifier">:simply_versioned_create_version</span>
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
-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
-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">&</span><span class="ruby-identifier">:to_s</span> )
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">&</span><span class="ruby-identifier">:to_s</span> )
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
-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
+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
@@ -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
- <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
@@ -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
- <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>