1
0
Fork 0
mirror of https://github.com/paper-trail-gem/paper_trail.git synced 2022-11-09 11:33:19 -05:00
Commit graph

22 commits

Author SHA1 Message Date
Jared Beck
4ef8a0bfed Queries: object_changes: Simplify error instantiation
- Introduces a uniform error class, UnsupportedColumnType
- Simplifies the built-in serializers (paper_trail/serializers)

Since 9.2.0, when `object_changes_adapter` was introduced, if someone must use a
text column, and still wants to use these queries, they must write an
`object_changes_adapter`. AFAIK, no one has ever done this. The only public
adapter I know of, paper_trail-hashdiff, only supports json/b columns.

It's also theoretically possible that, after `where_object_changes` dropped
support for text columns, someone wrote a custom serializer (see
`PaperTrail.serializer=`). AFAIK, no one has done that either. Such a technique
was never documented under [6.b. Custom
Serializer](https://github.com/paper-trail-gem/paper_trail#6b-custom-serializer)
2021-04-06 12:13:04 -04:00
Jared Beck
173dffa719 Introduce PaperTrail::Error class 2021-04-05 16:14:50 -04:00
Kevin Murphy
52881f2ece
Query Versions Where Attribute Changed (#1292)
This adds in a new query method `where_attribute_changes` which will
look for any versions where there was a change to the attribute
specified.

In instances where you need to look for any changes to a particular
attribute, but don't yet know, or don't care, what the value of the
attribute was that changed at all, this is intended to answer that
question.

Co-authored-by: Jared Beck <jared@jaredbeck.com>
2021-04-05 15:11:49 -04:00
Kevin Murphy
06a7c12534 Query Versions Where Object Changed To Attributes
This extends to the public API to provide more targeted
querying of object changes. `where_object_changes` will look for either
side of the change of the attributes provided - either versions where
the attribute changed __from__ the provided value, or changed __to__ the
provided value.

The `where_object_changes_to` addition focuses only on one
side of that equation. If you want to find versions where the
attribute(s) explicitly changed *to* some known value, this will only
show those changes, as opposed to both *from* and *to*.
2021-04-05 15:00:24 -04:00
Kevin Murphy
0007864e2e
Query Versions Where Object Changed From Attributes (#1286)
* Add rails-controller-testing

In order to get all of the tests to pass, this adds in and configures
rails-controller-testing so that `assigns`is available in controller and
integration tests.

* Query Versions Where Object Changed From Attributes

This proposes an extension to the public API to provide more targeted
querying of object changes. `where_object_changes` will look for either
side of the change of the attributes provided - either versions where
the attribute changed __from__ the provided value, or changed __to__ the
provided value.

The proposed `where_object_changes_from` addition focuses only on one
side of that equation. If you want to find versions where the
attribute(s) explicitly changed *from* some known value, this will only
show those changes, as opposed to both *from* and *to*.

* Custom Serializer where_object_changes_from implementation

This mirrors the implementation of WhereObjectChanges#text in
WhereObjectChangesFrom#text in the case of a custom serializer. The
provided YAML serializer does not support this method.

* Document New API Method for Custom Adapter

This provides awareness of the new method that custom object changes
adapters may need to implement to support this change.

* remove rails-controller-testing
2021-02-22 18:50:57 -05:00
Anton Rieder
8f8f5587e9
Change URLs to paper-trail-gem 2018-05-09 13:25:56 +02:00
Jared Beck
b7b4119147 Require AR and AS: require all and earlier
Fixes a rare issue with load order when using PT outside of rails.
2018-01-31 12:25:31 -05:00
Jared Beck
cfbf7a647c Lint: Style/FrozenStringLiteralComment 2017-12-10 23:05:39 -05:00
Jared Beck
325e368c4c Raise error re: where_object_changes, YAML
Using where_object_changes to read YAML from a text column will now raise
error, was deprecated in 8.1.0.
2017-12-10 22:42:16 -05:00
Jared Beck
3e0669b5ed where_object_changes: reading json from text column: raise error
Breaking change.
2017-09-20 03:53:51 -04:00
Jared Beck
6f452e4044 Add deprecation warning to where_object_changes
See discussion at https://github.com/airblade/paper_trail/issues/803
2017-07-09 00:30:18 -04:00
Jared Beck
1125b96594 Docs: re: where_object_changes
[ci skip]
2016-05-10 17:16:35 -04:00
Jared Beck
a0e3f43ad1 Docs: Describe all modules 2016-04-09 01:08:34 -04:00
Jared Beck
9ec7bb82af Fix Style/FirstParameterIndentation 2016-03-13 20:04:08 -04:00
Jared Beck
8980f08d0e Fix Style/StringLiterals: Use double quotes 2016-03-05 17:07:32 -05:00
Ben Atkins
4a92ed7ea5 close #420; Add VersionConcern#where_object_changes 2015-01-07 16:57:45 -05:00
Jacob Evelyn
703ec9ae88 Add where_object query to PaperTrail::Version. 2014-06-07 14:11:50 -04:00
Ben Atkins
b32ced84c5 Upcasing the provided YAML and JSON serializers 2013-10-17 22:05:24 -04:00
Ben Atkins
f54ada67e2 Making the built-in serializers declare 'extend self' so that their :load and :dump methods are available as module methods and instance methods. This enables classes/modules that mix in one of these serializers to invoke or override the methods. Close #196 2013-01-31 15:10:31 -05:00
Ben Atkins
64758ca163 Fixing some comments in the serializer tests to be accurate. Also tweaking the syntax of the 'dump' methods in the serializers to clarify that the serializers can acceptobjects other than just Hashes (even though PaperTrail will only pass attribute hashes to the serializers). 2013-01-31 11:22:03 -05:00
Ben Atkins
05301e586e Refactoring the serializers to be modules instead of classes, since they never get instantiated. 2013-01-23 15:56:10 -05:00
Ben Atkins
526e6ae7cc Adding JSON serializer to the gem. Close #194 2013-01-22 18:13:58 -05:00