module Footprintable::ClassMethods
Public Instance Methods
has_footprints(options = {})
click to toggle source
# File lib/footprintable/class_methods.rb, line 4 def has_footprints options = {} # 触发时间 options[:on] ||= [:create, :update, :destroy] # 摘取字段 [] => 所有字段 options[:extract] ||= [] # 排除字段 options[:except] ||= [:updated_at, :created_at] self.footprint_options = options setup_callbacks_from_options(options[:on]) end
setup_callbacks_from_options(options_on = [])
click to toggle source
# File lib/footprintable/class_methods.rb, line 15 def setup_callbacks_from_options options_on = [] options_on.each do |action| after_commit ->(obj) { obj.create_footprint action }, on: action end end