Module: MagicUserstamp::Stampable

Defined in:
lib/magic_userstamp/stampable.rb

Overview

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.

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object

:nodoc:



32
33
34
35
36
37
38
39
# File 'lib/magic_userstamp/stampable.rb', line 32

def self.included(base) #:nodoc:
  base.extend(ClassMethods)
  base.class_eval do
    # Should ActiveRecord record userstamps? Defaults to true.
    class_inheritable_accessor  :record_userstamp
    self.record_userstamp = true
  end
end

.raise_unless_valid_options_for_stampable_on(options) ⇒ Object



41
42
43
44
45
# File 'lib/magic_userstamp/stampable.rb', line 41

def self.raise_unless_valid_options_for_stampable_on(options)
  return if options.nil?
  invalid_keys = (options.keys - VALID_OPTIONS_KEYS_FOR_STAMPABLE_ON)
  raise "Invalid options keys: #{invalid_keys.inspect}" unless invalid_keys.empty?
end