module PaperTrail
An ActiveRecord extension that tracks changes to your models, for auditing or versioning.
Constants
- E_RAILS_NOT_LOADED
- E_TIMESTAMP_FIELD_CONFIG
Public Class Methods
Returns PaperTrail's global configuration object, a singleton. These settings affect all threads. @api private
# File lib/mongo_trails.rb, line 116 def config @config ||= PaperTrail::Config.instance yield @config if block_given? @config end
Switches PaperTrail
on or off, for all threads. @api public
# File lib/mongo_trails.rb, line 50 def enabled=(value) PaperTrail.config.enabled = value end
Returns `true` if PaperTrail
is on, `false` otherwise. This is the on/off switch that affects all threads. Enabled by default. @api public
# File lib/mongo_trails.rb, line 57 def enabled? !!PaperTrail.config.enabled end
Returns PaperTrail's `::Gem::Version`, convenient for comparisons. This is recommended over `::PaperTrail::VERSION::STRING`.
Added in 7.0.0
@api public
# File lib/mongo_trails.rb, line 67 def gem_version ::Gem::Version.new(VERSION::STRING) end
Set variables for the current request, eg. whodunnit.
All request-level variables are now managed here, as of PT 9. Having the word “request” right there in your application code will remind you that these variables only affect the current request, not all threads.
Given a block, temporarily sets the given `options`, executes the block, and returns the value of the block.
Without a block, this currently just returns `PaperTrail::Request`. However, please do not use `PaperTrail::Request` directly. Currently, `Request` is a `Module`, but in the future it is quite possible we may make it a `Class`. If we make such a choice, we will not provide any warning and will not treat it as a breaking change. You've been warned :)
@api public
# File lib/mongo_trails.rb, line 87 def request(options = nil, &block) if options.nil? && !block_given? Request else Request.with(options, &block) end end
Get the PaperTrail
serializer used by all threads. @api public
# File lib/mongo_trails.rb, line 109 def serializer PaperTrail.config.serializer end
Set the PaperTrail
serializer. This setting affects all threads. @api public
# File lib/mongo_trails.rb, line 103 def serializer=(value) PaperTrail.config.serializer = value end
Set the field which records when a version was created. @api public
# File lib/mongo_trails.rb, line 97 def timestamp_field=(_field_name) raise(E_TIMESTAMP_FIELD_CONFIG) end
# File lib/mongo_trails.rb, line 123 def version VERSION::STRING end