Sha256: 28bff5a5587485b2fbd242e5688ee3a636c8bbf52a5fabcc05d11792cd532c30

Contents?: true

Size: 1 KB

Versions: 35

Compression:

Stored size: 1 KB

Contents

module Cms
  module Behaviors
    module Userstamping
      def self.included(model_class)
        model_class.extend(MacroMethods)
      end
      module MacroMethods      
        def userstamped?
          !!@is_userstamped
        end
        def is_userstamped(options={})
          @is_userstamped = true
          extend ClassMethods
          include InstanceMethods
        
          belongs_to :created_by, :class_name => "User"
          belongs_to :updated_by, :class_name => "User"
        
          before_save :set_userstamps
        
          named_scope :created_by, lambda{|user| {:conditions => {:created_by => user}}}        
          named_scope :updated_by, lambda{|user| {:conditions => {:updated_by => user}}}        
        end
      end
      module ClassMethods
      end
      module InstanceMethods
        def set_userstamps
          if new_record?
            self.created_by = User.current 
          end
          self.updated_by = User.current
        end
      end
    end
  end
end

Version data entries

35 entries across 35 versions & 11 rubygems

Version Path
SFEley-browsercms-3.0.2 lib/cms/behaviors/userstamping.rb
buzzware-browsercms-3.0.2 lib/cms/behaviors/userstamping.rb
coredumplings-browsercms-3.0.0 lib/cms/behaviors/userstamping.rb
nate-browsercms-3.0.210 lib/cms/behaviors/userstamping.rb
nate-browsercms-3.0.211 lib/cms/behaviors/userstamping.rb
we5-browsercms-3.0.1.1 lib/cms/behaviors/userstamping.rb
webficient-browsercms-3.0.1 lib/cms/behaviors/userstamping.rb
webficient-browsercms-3.0.2 lib/cms/behaviors/userstamping.rb
webficient-browsercms-3.0.3 lib/cms/behaviors/userstamping.rb
webficient-browsercms-3.0.4 lib/cms/behaviors/userstamping.rb
browsercms-3.1.5 lib/cms/behaviors/userstamping.rb
browsercms-3.1.4 lib/cms/behaviors/userstamping.rb
browsercms-3.1.3 lib/cms/behaviors/userstamping.rb
bf4-browsercms-3.1.0 lib/cms/behaviors/userstamping.rb
drujensen-browsercms-3.2.0 lib/cms/behaviors/userstamping.rb
browsercmsi-3.1.2 lib/cms/behaviors/userstamping.rb
browsercms-3.1.2 lib/cms/behaviors/userstamping.rb
browsercms-3.1.1 lib/cms/behaviors/userstamping.rb
browsercmsi-3.1.1 lib/cms/behaviors/userstamping.rb
browsercmsi-3.1.0 lib/cms/behaviors/userstamping.rb