2012-10-30 16:01:13 -04:00
|
|
|
require 'singleton'
|
|
|
|
|
2010-03-19 11:21:07 -04:00
|
|
|
module PaperTrail
|
|
|
|
class Config
|
|
|
|
include Singleton
|
2013-05-23 15:56:19 -04:00
|
|
|
attr_accessor :enabled, :timestamp_field, :serializer, :version_limit
|
2014-12-29 14:38:32 -05:00
|
|
|
attr_reader :serialized_attributes
|
2012-07-03 23:22:52 -04:00
|
|
|
|
2010-03-19 11:21:07 -04:00
|
|
|
def initialize
|
2012-12-28 01:12:42 -05:00
|
|
|
@enabled = true # Indicates whether PaperTrail is on or off.
|
2012-02-01 14:47:06 -05:00
|
|
|
@timestamp_field = :created_at
|
2013-10-17 22:05:24 -04:00
|
|
|
@serializer = PaperTrail::Serializers::YAML
|
2014-12-29 14:38:32 -05:00
|
|
|
|
|
|
|
# This setting only defaults to false on AR 4.2+, because that's when
|
|
|
|
# it was deprecated. We want it to function with older versions of
|
|
|
|
# ActiveRecord by default.
|
|
|
|
if ::ActiveRecord::VERSION::STRING < '4.2'
|
|
|
|
@serialized_attributes = true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def serialized_attributes=(value)
|
|
|
|
if ::ActiveRecord::VERSION::MAJOR >= 5
|
|
|
|
warn("DEPRECATED: ActiveRecord 5.0 deprecated `serialized_attributes` " +
|
|
|
|
"without replacement, so this PaperTrail config setting does " +
|
|
|
|
"nothing with this version, and is always turned off")
|
|
|
|
end
|
|
|
|
@serialized_attributes = value
|
2010-03-19 11:21:07 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|