paper_trail-active_record 0.1.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7fa97181a35e9ee580bb03d4bdef4da4d9a05aa6d90561274df1d8a69c08445c
4
- data.tar.gz: 6888e2d9591bf6764bb66abba3dfd85b4e82d7a7a3628f2b6862473aa9b356f8
3
+ metadata.gz: 934cfc40b232a8284fdd96e5b6ee941bbcbf743cad7efc46615f1b41e1de7ec4
4
+ data.tar.gz: 2a9ce631a65f989b558343f340b9fd56b1aed9d9cc421b3f10e2593d52de3d74
5
5
  SHA512:
6
- metadata.gz: 953db9408ab0369e96e693ec79546eacd299b0009635546740222358525bf21d42f1c91f6c2b7024e183d3e11e53b73630eabd0d7ac34ca919585596cf7ef3a0
7
- data.tar.gz: e9e680685bcb3c5de6f575c515f53432639338d59514cc259b3f4c579a02a428d5d7a8a19989c97b3537ba5bad673020cb704c5b8e3430ba197148316f1fb815
6
+ metadata.gz: cce01fc8714b7573a877c02f0c190559b466ce13c35168a9e77ed85d8286f412afb850a3fc1b70283e98295334fb6e2beffb2f4eba1b8d80dfd696bf94ff3898
7
+ data.tar.gz: 16d19245089055b4697aa1de1046d64de445d555e1490e1468cd5a5d3a9ac03cf667989edf40863d0ecf8a5aa168f0b8c3162709d11f3954970627452aeed8b4
data/Changelog.md CHANGED
@@ -1,3 +1,21 @@
1
+ ## 1.0.0 (2022-04-27)
2
+
3
+ Breaking changes:
4
+ - `PaperTrail::ActiveRecord` was renamed to `PaperTrail::ActiveRecordExt` to fix this error with paper_trail 12.3.0 / rails 7:
5
+
6
+ NameError:
7
+ uninitialized constant PaperTrail::ActiveRecord::Type
8
+
9
+ elsif PaperTrail::RAILS_GTE_7_0 && val.is_a?(ActiveRecord::Type::Time::Value)
10
+
11
+ ## 0.1.2 (2020-04-27)
12
+
13
+ - Fix: Remove debug output
14
+
15
+ ## 0.1.1 (2020-04-23)
16
+
17
+ - Fix: `has_many_versions` was passing wrong value for extends
18
+
1
19
  ## 0.1.0 (2020-04-23)
2
20
 
3
21
  Initial release
data/Readme.md CHANGED
@@ -1,10 +1,10 @@
1
- # PaperTrail::ActiveRecord
1
+ # PaperTrail::ActiveRecordExt
2
2
 
3
3
  [![Gem Version][1]][2]
4
4
  [![Yard Docs](http://img.shields.io/badge/yard-docs-blue.svg)](https://rdoc.info/github/TylerRick/paper_trail-active_record/master)
5
5
 
6
- An extension to [PaperTrail](https://github.com/paper-trail-gem/paper_trail)
7
- that adds some useful extensions to models that have `has_paper_trail` and to the Version model.
6
+ Various ActiveRecord extensions to make your life easier when working with
7
+ [PaperTrail](https://github.com/paper-trail-gem/paper_trail) versions and versioned model records.
8
8
 
9
9
  ## Methods added to models with `has_paper_trail`
10
10
 
@@ -27,25 +27,7 @@ that adds some useful extensions to models that have `has_paper_trail` and to th
27
27
  - `#action`
28
28
  - `#item_class`
29
29
 
30
- ## `OrDeleted`
31
-
32
- If you include this module into a model, it will automatically add a `{association}_or_deleted`
33
- method for every `belongs_to` or `has_one` association that is defined.
34
-
35
- Because it reflects on all associations on that model as soon as it is included, make sure to
36
- include it *after* all of your associations are defined.
37
-
38
- If you want more control, and don't want it to add anything automatically, you can manually call
39
- `define_assoc_or_deleted :association` for each association that you want to have a
40
- `{association}_or_deleted` method.
41
-
42
- If you want it to automatically be added for all assocations on *all* application models, you can
43
- use [gem 'active_record_include'](https://github.com/TylerRick/active_record_include) like this:
44
-
45
- ```ruby
46
- class ApplicationRecord < ActiveRecord::Base
47
- include_when_connected PaperTrail::ActiveRecord::OrDeleted
48
- ```
30
+ ## `{association}_or_deleted`
49
31
 
50
32
  ### `def define_assoc_or_deleted(assoc_name, suffix: nil)`
51
33
 
@@ -66,6 +48,23 @@ class Post
66
48
  define_assoc_or_deleted :author, suffix: nil
67
49
  ```
68
50
 
51
+ ### Automatically add for all assocations
52
+
53
+ If you include `PaperTrail::ActiveRecordExt::OrDeleted` into a model, it will automatically add a `{association}_or_deleted`
54
+ method for every `belongs_to` or `has_one` association that is defined.
55
+
56
+ Because it reflects on all associations on that model as soon as it is included, make sure to
57
+ include it *after* all of your associations are defined. You can also call
58
+ `define_assoc_or_deleted_on_all_associations` at the end of your model class (that is the same
59
+ method that including the module triggers).
60
+
61
+ If you want it to automatically be added for all assocations on *all* application models, you can
62
+ use [gem 'active_record_include'](https://github.com/TylerRick/active_record_include) like this:
63
+
64
+ ```ruby
65
+ class ApplicationRecord < ActiveRecord::Base
66
+ include_when_connected PaperTrail::ActiveRecordExt::OrDeleted
67
+ ```
69
68
 
70
69
 
71
70
  ## Installation
data/bin/console CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require "bundler/setup"
4
- require "paper_trail/rails"
4
+ require "paper_trail/active_record"
5
5
 
6
6
  # You can add fixtures and/or initialization code here to make experimenting
7
7
  # with your gem easier. You can also use a different console, if you like.
@@ -1,4 +1,4 @@
1
- module PaperTrail::ActiveRecord
1
+ module PaperTrail::ActiveRecordExt
2
2
 
3
3
  # Extensions to ActiveRecord::Base to better support PaperTrail
4
4
  module BaseExtensions
@@ -13,7 +13,7 @@ module BaseExtensions
13
13
  else
14
14
  Version.where(item_type: base_class.name, item_subtype: self.name)
15
15
  end.tap do |versions|
16
- PaperTrail::ActiveRecord.config.versions_extends.each do |mod|
16
+ PaperTrail::ActiveRecordExt.config.versions_extends.each do |mod|
17
17
  versions.extend(mod)
18
18
  end
19
19
  end
@@ -51,7 +51,7 @@ module BaseExtensions
51
51
  end
52
52
 
53
53
  def has_many_versions(name, *args, **options)
54
- has_many name, *args, class_name: 'Version', extend: [PaperTrail::ActiveRecord.config.versions_extends], **options
54
+ has_many name, *args, class_name: 'Version', extend: PaperTrail::ActiveRecordExt.config.versions_extends, **options
55
55
  end
56
56
 
57
57
  # Creates associations for finding related versions — that is, versions for related/children
@@ -123,6 +123,6 @@ end
123
123
  end
124
124
 
125
125
  ActiveRecord::Base.class_eval do
126
- include PaperTrail::ActiveRecord::BaseExtensions
126
+ include PaperTrail::ActiveRecordExt::BaseExtensions
127
127
  end
128
128
 
@@ -1,5 +1,5 @@
1
1
  module PaperTrail
2
- module ActiveRecord
2
+ module ActiveRecordExt
3
3
  class Configuration
4
4
  def initialize
5
5
  config = self
@@ -1,4 +1,4 @@
1
- module PaperTrail::ActiveRecord
1
+ module PaperTrail::ActiveRecordExt
2
2
 
3
3
  # If you include this module into a model, it will automatically add a `{association}_or_deleted`
4
4
  # method for every `belongs_to` or `has_one` association that is defined.
@@ -69,7 +69,7 @@ module OrDeleted
69
69
 
70
70
  def define_assoc_or_deleted_on_all_associations(suffix: 'or_deleted')
71
71
  reflect_on_all_associations.each do |reflection|
72
- puts %(#{self}.reflection.name=#{(reflection.name).inspect})
72
+ #puts %(#{self}.reflection.name=#{(reflection.name).inspect})
73
73
  next if reflection.collection?
74
74
 
75
75
  assoc_name = reflection.name
@@ -1,7 +1,7 @@
1
1
  module PaperTrail
2
- module ActiveRecord
2
+ module ActiveRecordExt
3
3
  def self.version
4
- "0.1.0"
4
+ "1.0.0"
5
5
  end
6
6
  end
7
7
  end
@@ -1,4 +1,6 @@
1
- module PaperTrail::ActiveRecord
1
+ require 'paper_trail/version_concern'
2
+
3
+ module PaperTrail::ActiveRecordExt
2
4
  module VersionConcernExt
3
5
  extend ActiveSupport::Concern
4
6
 
@@ -70,7 +72,7 @@ end
70
72
  end
71
73
 
72
74
  PaperTrail::VersionConcern.class_eval do
73
- prepend PaperTrail::ActiveRecord::VersionConcernExt
74
- include PaperTrail::ActiveRecord::VersionConcernExt
75
+ prepend PaperTrail::ActiveRecordExt::VersionConcernExt
76
+ include PaperTrail::ActiveRecordExt::VersionConcernExt
75
77
  end
76
78
 
@@ -1,4 +1,6 @@
1
+ require 'active_record'
1
2
  require 'paper_trail'
3
+ require 'paper_trail/frameworks/active_record'
2
4
 
3
5
  require_relative 'active_record/version'
4
6
 
@@ -8,7 +10,7 @@ require_relative 'active_record/or_deleted'
8
10
  require_relative 'active_record/version_extensions'
9
11
 
10
12
  module PaperTrail
11
- module ActiveRecord
13
+ module ActiveRecordExt
12
14
  class << self
13
15
  def configuration
14
16
  @configuration ||= Configuration.new
@@ -5,11 +5,11 @@ require "paper_trail/active_record/version"
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "paper_trail-active_record"
8
- spec.version = PaperTrail::ActiveRecord.version
8
+ spec.version = PaperTrail::ActiveRecordExt.version
9
9
  spec.authors = ["Tyler Rick"]
10
10
  spec.email = ["tyler@tylerrick.com"]
11
11
 
12
- spec.summary = %q{Various ActiveRecord extensions}
12
+ spec.summary = %q{Various ActiveRecord extensions to make your life easier when working with PaperTrail versions}
13
13
  spec.description = spec.summary
14
14
  spec.homepage = "https://github.com/TylerRick/#{spec.name}"
15
15
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paper_trail-active_record
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tyler Rick
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-04-24 00:00:00.000000000 Z
11
+ date: 2022-04-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: paper_trail
@@ -136,7 +136,8 @@ dependencies:
136
136
  - - ">="
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
- description: Various ActiveRecord extensions
139
+ description: Various ActiveRecord extensions to make your life easier when working
140
+ with PaperTrail versions
140
141
  email:
141
142
  - tyler@tylerrick.com
142
143
  executables: []
@@ -182,8 +183,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
182
183
  - !ruby/object:Gem::Version
183
184
  version: '0'
184
185
  requirements: []
185
- rubygems_version: 3.0.3
186
+ rubygems_version: 3.3.3
186
187
  signing_key:
187
188
  specification_version: 4
188
- summary: Various ActiveRecord extensions
189
+ summary: Various ActiveRecord extensions to make your life easier when working with
190
+ PaperTrail versions
189
191
  test_files: []