module Thoth::Rails::Model::ClassMethods
Public Instance Methods
log_events(options={})
click to toggle source
# File lib/thoth/rails/model.rb, line 9 def log_events(options={}) defaults = {on: [:create, :update, :destroy]} options = options.reverse_merge!(defaults) options[:on] = Array(options[:on]) options[:only] = Array(options[:only]) class_attribute :thoth_options self.thoth_options = options after_create :thoth_log_create if options[:on].include?(:create) before_update :thoth_log_update if options[:on].include?(:update) after_destroy :thoth_log_destroy if options[:on].include?(:destroy) end