Skip to content

Commit

Permalink
Merge pull request #863 from airblade/deprecate_timestamp_config
Browse files Browse the repository at this point in the history
Deprecate timestamp_field=
  • Loading branch information
jaredbeck committed Sep 8, 2016
2 parents 8eef72a + 03568b3 commit 55ddc0d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
7 changes: 7 additions & 0 deletions lib/paper_trail.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,19 @@ def enabled_for_model?(model)

# Set the field which records when a version was created.
# @api public
# @deprecated
def timestamp_field=(field_name)
::ActiveSupport::Deprecation.warn(
"PaperTrail.timestamp_field= is deprecated without replacement." \
"See https://github.com/airblade/paper_trail/pull/861 for discussion",
caller(1)
)
PaperTrail.config.timestamp_field = field_name
end

# Returns the field which records when a version was created.
# @api public
# @deprecated
def timestamp_field
PaperTrail.config.timestamp_field
end
Expand Down
15 changes: 14 additions & 1 deletion lib/paper_trail/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ module PaperTrail
# configuration can be found in `paper_trail.rb`, others in `controller.rb`.
class Config
include Singleton
attr_accessor :timestamp_field, :serializer, :version_limit
attr_accessor :serializer, :version_limit
attr_reader :timestamp_field # deprecated
attr_writer :track_associations

def initialize
Expand Down Expand Up @@ -34,6 +35,18 @@ def serialized_attributes=(_)
)
end

# Set the field which records when a version was created.
# @api public
# @deprecated
def timestamp_field=(field_name)
::ActiveSupport::Deprecation.warn(
"PaperTrail.config.timestamp_field= is deprecated without replacement." \
"See https://github.com/airblade/paper_trail/pull/861 for discussion",
caller(1)
)
@timestamp_field = field_name
end

# Previously, we checked `PaperTrail::VersionAssociation.table_exists?`
# here, but that proved to be problematic in situations when the database
# connection had not been established, or when the database does not exist
Expand Down

0 comments on commit 55ddc0d

Please sign in to comment.