It breaks the build because it requires rubocop 0.47, which
we have not upgraded to yet.
I'm not sure how the addition of rubocop-thread_safety passed CI.
I want to try it out, but don't want to upgrade rubocop right now.
- ruby 2.3.1 (was 2.3.0)
- Update AR5 gemfile now that rails 5 is out
- Enable travis bundler cache. Hopefully this will speed up travis a bit.
https://docs.travis-ci.com/user/caching/
- set TargetRubyVersion: 1.9
Problem
-------
`has_paper_trail` adds too many methods to the ActiveRecord model.
> If I'm counting correctly, installing the paper_trail gem adds 36 instance
> methods and 10 class methods to all of your active record models. Of those
> 46, 13 have a prefix, either "pt_" or "paper_trail_". I don't know what the
> best way to deal with this is. Ideally, we'd add far fewer methods to
> people's models. If we were able to add fewer methods to models, then I
> wouldn't mind prefixing all of them.
> https://github.com/airblade/paper_trail/issues/703
Solution
--------
Add only two methods to the AR model.
1. An instance method `#paper_trail`
2. A class method `.paper_trail`
The instance method would return a `RecordTrail` and the class method would
return a `ClassTrail`. Those names are totally up for debate.
Advantages
----------
- Plain ruby, easy to understand
- Adding new methods to e.g. the `RecordTrail` does not add any methods to
the AR model.
- Methods privacy is more strongly enforced.
- Enables isolated testing of e.g. `RecordTrail`; it can be constructed with a
mock AR instance.
Disadvantages
-------------
- Two new classes, though they are simple.
The registration of these two modules does not need to occur,
lexically, within the PaperTrail module.
The only lexical contents of a module should be methods, constants,
and statements which require that specific lexical scope.
The number of lines in a method is not a useful metric compared to `AbcSize`.
It's common to have very long methods (> 50 lines) which are quite simple. For
example, a method that returns a long string with only a few interpolations.
[ci skip]