Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Revert "Addition of automatic_mode option and change to setting of cr…

…eator attribute"

This reverts commit 9cc7c9e.
  • Loading branch information...
commit af0f1755d885c51d5e6d8fd61b6df0efa0f3dc55 1 parent 9cc7c9e
@chrismhilton chrismhilton authored
Showing with 4 additions and 25 deletions.
  1. +1 −6 Readme.rdoc
  2. +3 −19 lib/stampable.rb
View
7 Readme.rdoc
@@ -20,11 +20,6 @@ results in associations defined like so:
belongs_to :creator, :class_name => "::User", :foreign_key => :created_by, :with_deleted => true
-This fork also includes the addition of the automatic_mode option which controls whether whether classes that inherit from ActiveRecord are made stampable automatically. To turn automatic mode off, place the following line in your environment.rb
-
- Ddb::Userstamp.automatic_mode = false
-
-This fork also includes a change so that the creator attribute is only set if its value is blank allowing for a manual override.
== Using the Fork
@@ -35,7 +30,7 @@ To use this fork add the following to your application gemfile:
== Overview
-Userstamp extends ActiveRecord::Base[http://api.rubyonrails.com/classes/ActiveRecord/Base.html] to add automatic or selective updating of 'creator',
+Userstamp extends ActiveRecord::Base[http://api.rubyonrails.com/classes/ActiveRecord/Base.html] to add automatic updating of 'creator',
'updater', and 'deleter' attributes. It is based loosely on the ActiveRecord::Timestamp[http://api.rubyonrails.com/classes/ActiveRecord/Timestamp.html] module.
Two class methods (<tt>model_stamper</tt> and <tt>stampable</tt>) are implemented in this plugin.
View
22 lib/stampable.rb
@@ -14,19 +14,6 @@ module Userstamp
mattr_accessor :compatibility_mode
@@compatibility_mode = false
- # Determines whether classes that inherit from ActiveRecord
- # are made stampable automatically (default)
- # or selectively in which case the method must be called within each
- # model that needs to be stamped.
- #
- # To turn automatic mode off, place the following line in your environment.rb
- # file:
- #
- # Ddb::Userstamp.automatic_mode = false
- #
- mattr_accessor :automatic_mode
- @@automatic_mode = true
-
# Extends the stamping functionality of ActiveRecord by automatically recording the model
# responsible for creating, updating, and deleting the current object. See the Stamper
# and Userstamp modules for further documentation on how the entire process works.
@@ -60,14 +47,13 @@ def self.included(base) #:nodoc:
# Defaults to :deleted_by when compatibility mode is on
class_attribute :deleter_attribute
- self.stampable if Ddb::Userstamp.automatic_mode == true
+ self.stampable
end
end
module ClassMethods
# This method is automatically called on for all classes that inherit from
- # ActiveRecord when using the default automatic mode
- # but if you need to customize how the plug-in functions, this is the
+ # ActiveRecord, but if you need to customize how the plug-in functions, this is the
# method to use. Here's an example:
#
# class Post < ActiveRecord::Base
@@ -160,9 +146,7 @@ def has_stamper?
def set_creator_attribute
return unless self.record_userstamp
if respond_to?(self.creator_attribute.to_sym) && has_stamper?
- if self.send(self.creator_attribute.to_sym).blank?
- self.send("#{self.creator_attribute}=".to_sym, self.class.stamper_class.stamper)
- end
+ self.send("#{self.creator_attribute}=".to_sym, self.class.stamper_class.stamper)
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.