Skip to content

Commit 55ddc0d

Browse files
authored
Merge pull request #863 from airblade/deprecate_timestamp_config
Deprecate timestamp_field=
2 parents 8eef72a + 03568b3 commit 55ddc0d

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

lib/paper_trail.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,19 @@ def enabled_for_model?(model)
7272

7373
# Set the field which records when a version was created.
7474
# @api public
75+
# @deprecated
7576
def timestamp_field=(field_name)
77+
::ActiveSupport::Deprecation.warn(
78+
"PaperTrail.timestamp_field= is deprecated without replacement." \
79+
"See https://github.com/airblade/paper_trail/pull/861 for discussion",
80+
caller(1)
81+
)
7682
PaperTrail.config.timestamp_field = field_name
7783
end
7884

7985
# Returns the field which records when a version was created.
8086
# @api public
87+
# @deprecated
8188
def timestamp_field
8289
PaperTrail.config.timestamp_field
8390
end

lib/paper_trail/config.rb

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ module PaperTrail
66
# configuration can be found in `paper_trail.rb`, others in `controller.rb`.
77
class Config
88
include Singleton
9-
attr_accessor :timestamp_field, :serializer, :version_limit
9+
attr_accessor :serializer, :version_limit
10+
attr_reader :timestamp_field # deprecated
1011
attr_writer :track_associations
1112

1213
def initialize
@@ -34,6 +35,18 @@ def serialized_attributes=(_)
3435
)
3536
end
3637

38+
# Set the field which records when a version was created.
39+
# @api public
40+
# @deprecated
41+
def timestamp_field=(field_name)
42+
::ActiveSupport::Deprecation.warn(
43+
"PaperTrail.config.timestamp_field= is deprecated without replacement." \
44+
"See https://github.com/airblade/paper_trail/pull/861 for discussion",
45+
caller(1)
46+
)
47+
@timestamp_field = field_name
48+
end
49+
3750
# Previously, we checked `PaperTrail::VersionAssociation.table_exists?`
3851
# here, but that proved to be problematic in situations when the database
3952
# connection had not been established, or when the database does not exist

0 commit comments

Comments
 (0)