Class: CreatedAndUpdatedBy::Stamper

Inherits:
Object
  • Object
show all
Includes:
ActiveSupport::CoreExtensions
Defined in:
lib/created-and-updated-by.rb

Class Method Summary collapse

Class Method Details

.attach(stamp_model = :User, stamp_attribute = :current) ⇒ Object

Raises:

  • (ArgumentError)


9
10
11
12
13
# File 'lib/created-and-updated-by.rb', line 9

def self.attach(stamp_model = :User, stamp_attribute = :current)
	raise ArgumentError, "#{stamp_model} does not respond to #{stamp_attribute}" unless Object.const_get(stamp_model).respond_to?(stamp_attribute)
	self.stampable, self.attribute = stamp_model, stamp_attribute
	ActiveRecord::Base.send(:include, CreatedAndUpdatedBy)
end