mirror of
https://github.com/paper-trail-gem/paper_trail.git
synced 2022-11-09 11:33:19 -05:00
24f3fbcd8f
See historical overview in README
39 lines
1,003 B
Ruby
39 lines
1,003 B
Ruby
# frozen_string_literal: true
|
|
|
|
require "singleton"
|
|
require "paper_trail/serializers/yaml"
|
|
|
|
module PaperTrail
|
|
# Global configuration affecting all threads. Some thread-specific
|
|
# configuration can be found in `paper_trail.rb`, others in `controller.rb`.
|
|
class Config
|
|
include Singleton
|
|
|
|
attr_accessor(
|
|
:association_reify_error_behaviour,
|
|
:object_changes_adapter,
|
|
:serializer,
|
|
:version_limit,
|
|
:has_paper_trail_defaults
|
|
)
|
|
|
|
def initialize
|
|
# Variables which affect all threads, whose access is synchronized.
|
|
@mutex = Mutex.new
|
|
@enabled = true
|
|
|
|
# Variables which affect all threads, whose access is *not* synchronized.
|
|
@serializer = PaperTrail::Serializers::YAML
|
|
@has_paper_trail_defaults = {}
|
|
end
|
|
|
|
# Indicates whether PaperTrail is on or off. Default: true.
|
|
def enabled
|
|
@mutex.synchronize { !!@enabled }
|
|
end
|
|
|
|
def enabled=(enable)
|
|
@mutex.synchronize { @enabled = enable }
|
|
end
|
|
end
|
|
end
|