Sha256: a3183a87a1642516e85e9daf8e4ce95e177d32f00f6df691ea1f855266914ce7
Contents?: true
Size: 801 Bytes
Versions: 10
Compression:
Stored size: 801 Bytes
Contents
module AbAdmin module Concerns module HasTracking extend ActiveSupport::Concern included do has_many :tracks, as: :trackable class_attribute :tracking_enabled self.tracking_enabled = true end def track(options={}) return unless tracking_enabled? options[:trackable] ||= self options[:owner] ||= user if respond_to?(:user) options[:user] ||= updater if respond_to?(:updater) options[:key] = [self.class.model_name.plural, options[:key]].compact.join('.') tracks.build(options) end def track!(*args) track(*args).save! end module ClassMethods def tracking_enabled? tracking_enabled && Track.tracking_enabled end end end end end
Version data entries
10 entries across 10 versions & 1 rubygems