paper_trail_diff 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +15 -0
  3. data/README.md +9 -0
  4. data/lib/paper_trail_diff/activity_belongs_to_event_applier.rb +126 -0
  5. data/lib/paper_trail_diff/activity_collection_event_applier.rb +137 -0
  6. data/lib/paper_trail_diff/activity_collection_record_updater.rb +67 -0
  7. data/lib/paper_trail_diff/activity_collection_route_change.rb +21 -0
  8. data/lib/paper_trail_diff/activity_collection_route_updater.rb +128 -0
  9. data/lib/paper_trail_diff/activity_event_record_normalizer.rb +42 -0
  10. data/lib/paper_trail_diff/activity_event_record_resolver.rb +120 -0
  11. data/lib/paper_trail_diff/activity_event_route_finder.rb +112 -0
  12. data/lib/paper_trail_diff/activity_event_snapshot_refresher.rb +56 -650
  13. data/lib/paper_trail_diff/activity_relationship.rb +55 -0
  14. data/lib/paper_trail_diff/branch_snapshot_refresher.rb +2 -0
  15. data/lib/paper_trail_diff/version.rb +1 -1
  16. data/lib/paper_trail_diff.rb +9 -0
  17. data/sig/generated/paper_trail_diff/activity_belongs_to_event_applier.rbs +41 -0
  18. data/sig/generated/paper_trail_diff/activity_collection_event_applier.rbs +46 -0
  19. data/sig/generated/paper_trail_diff/activity_collection_record_updater.rbs +25 -0
  20. data/sig/generated/paper_trail_diff/activity_collection_route_change.rbs +17 -0
  21. data/sig/generated/paper_trail_diff/activity_collection_route_updater.rbs +44 -0
  22. data/sig/generated/paper_trail_diff/activity_event_record_normalizer.rbs +19 -0
  23. data/sig/generated/paper_trail_diff/activity_event_record_resolver.rbs +44 -0
  24. data/sig/generated/paper_trail_diff/activity_event_route_finder.rbs +54 -0
  25. data/sig/generated/paper_trail_diff/activity_event_snapshot_refresher.rbs +18 -110
  26. data/sig/generated/paper_trail_diff/activity_relationship.rbs +23 -0
  27. metadata +22 -4
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+ # rbs_inline: enabled
3
+
4
+ module PaperTrailDiff
5
+ # Reads event-side foreign keys and matches them to an immutable snapshot owner.
6
+ class ActivityRelationship
7
+ #: (untyped, untyped, RecordSnapshot, ?state: Symbol) -> bool
8
+ def member_of_owner?(record, reflection, owner, state: :after)
9
+ actual = relationship_owner_values(record, reflection, state: state)
10
+ expected_ids = Array(owner.id)
11
+ # @type var expected_ids: Array[untyped]
12
+ expected = expected_ids.map { |id| id.to_s } # rubocop:disable Style/SymbolProc
13
+ return false unless actual == expected
14
+ return true unless reflection.options[:as]
15
+
16
+ type = event_attribute(record, reflection.type, state: state).to_s
17
+ owner_types(reflection, owner).include?(type)
18
+ end
19
+
20
+ #: (untyped, untyped, state: Symbol) -> untyped
21
+ def owner_id(record, reflection, state:)
22
+ values = Array(reflection.foreign_key).map do |foreign_key|
23
+ event_attribute(record, foreign_key, state: state)
24
+ end
25
+ values.one? ? values.first : values
26
+ end
27
+
28
+ private
29
+
30
+ #: (untyped, untyped, state: Symbol) -> Array[String]
31
+ def relationship_owner_values(record, reflection, state:)
32
+ Array(reflection.foreign_key).map do |key|
33
+ event_attribute(record, key, state: state).to_s
34
+ end
35
+ end
36
+
37
+ #: (untyped, untyped, state: Symbol) -> untyped
38
+ def event_attribute(record, name, state:)
39
+ if record.is_a?(ActivitySnapshotDelta)
40
+ return state == :before ? record.before_value(name) : record.after_value(name)
41
+ end
42
+
43
+ record.public_send(name)
44
+ end
45
+
46
+ #: (untyped, RecordSnapshot) -> Array[String]
47
+ def owner_types(reflection, owner)
48
+ [
49
+ owner.type.to_s,
50
+ reflection.active_record.name.to_s,
51
+ reflection.active_record.base_class.name.to_s
52
+ ]
53
+ end
54
+ end
55
+ end
@@ -159,6 +159,8 @@ module PaperTrailDiff
159
159
 
160
160
  #: (Array[String]) -> [AssociationTree, SnapshotNormalizer]
161
161
  def components(branches)
162
+ return @components[branches] if @components.key?(branches)
163
+
162
164
  key = branches.sort.freeze
163
165
  @components[key] ||= build_components(key)
164
166
  end
@@ -2,5 +2,5 @@
2
2
  # rbs_inline: enabled
3
3
 
4
4
  module PaperTrailDiff
5
- VERSION = '0.3.0'
5
+ VERSION = '0.3.1'
6
6
  end
@@ -40,6 +40,15 @@ require_relative 'paper_trail_diff/comparison_batch'
40
40
  require_relative 'paper_trail_diff/snapshot_normalizer'
41
41
  require_relative 'paper_trail_diff/historical_snapshot_store'
42
42
  require_relative 'paper_trail_diff/timeline_snapshot_provider'
43
+ require_relative 'paper_trail_diff/activity_event_record_resolver'
44
+ require_relative 'paper_trail_diff/activity_event_route_finder'
45
+ require_relative 'paper_trail_diff/activity_relationship'
46
+ require_relative 'paper_trail_diff/activity_collection_route_change'
47
+ require_relative 'paper_trail_diff/activity_collection_record_updater'
48
+ require_relative 'paper_trail_diff/activity_collection_route_updater'
49
+ require_relative 'paper_trail_diff/activity_event_record_normalizer'
50
+ require_relative 'paper_trail_diff/activity_collection_event_applier'
51
+ require_relative 'paper_trail_diff/activity_belongs_to_event_applier'
43
52
  require_relative 'paper_trail_diff/activity_event_snapshot_refresher'
44
53
  require_relative 'paper_trail_diff/activity_root_snapshot_refresher'
45
54
  require_relative 'paper_trail_diff/branch_snapshot_refresher'
@@ -0,0 +1,41 @@
1
+ # Generated from lib/paper_trail_diff/activity_belongs_to_event_applier.rb with RBS::Inline
2
+
3
+ module PaperTrailDiff
4
+ # Applies selected non-polymorphic belongs-to target updates to a snapshot.
5
+ class ActivityBelongsToEventApplier
6
+ # : (route_finder: ActivityEventRouteFinder, record_resolver: ActivityEventRecordResolver, record_normalizer: ActivityEventRecordNormalizer) -> void
7
+ def initialize: (route_finder: ActivityEventRouteFinder, record_resolver: ActivityEventRecordResolver, record_normalizer: ActivityEventRecordNormalizer) -> void
8
+
9
+ # : (untyped, untyped, RecordSnapshot, AssociationTree, SnapshotNormalizer, untyped) -> [bool, RecordSnapshot?]
10
+ def call: (untyped, untyped, RecordSnapshot, AssociationTree, SnapshotNormalizer, untyped) -> [ bool, RecordSnapshot? ]
11
+
12
+ private
13
+
14
+ @record_normalizer: ActivityEventRecordNormalizer
15
+
16
+ @record_resolver: ActivityEventRecordResolver
17
+
18
+ @route_finder: ActivityEventRouteFinder
19
+
20
+ # : (Array[untyped], untyped, SnapshotNormalizer, untyped, untyped) -> RecordSnapshot?
21
+ def normalized_route_record: (Array[untyped], untyped, SnapshotNormalizer, untyped, untyped) -> RecordSnapshot?
22
+
23
+ # : (RecordSnapshot, Array[untyped], untyped, RecordSnapshot?, ?depth: Integer) -> [RecordSnapshot, bool]
24
+ def replace_route: (RecordSnapshot, Array[untyped], untyped, RecordSnapshot?, ?depth: Integer) -> [ RecordSnapshot, bool ]
25
+
26
+ # : (Array[RecordSnapshot], Array[untyped], untyped, RecordSnapshot?, Integer) -> [Array[RecordSnapshot], bool]
27
+ def replacement_records: (Array[RecordSnapshot], Array[untyped], untyped, RecordSnapshot?, Integer) -> [ Array[RecordSnapshot], bool ]
28
+
29
+ # : (Array[RecordSnapshot], untyped, RecordSnapshot?) -> [Array[RecordSnapshot], bool]
30
+ def replace_existing_target: (Array[RecordSnapshot], untyped, RecordSnapshot?) -> [ Array[RecordSnapshot], bool ]
31
+
32
+ # : (RecordSnapshot, String, AssociationSnapshot) -> RecordSnapshot
33
+ def replace_association: (RecordSnapshot, String, AssociationSnapshot) -> RecordSnapshot
34
+
35
+ # : (untyped, RecordSnapshot?) -> String
36
+ def replacement_type: (untyped, RecordSnapshot?) -> String
37
+
38
+ # : (untyped) -> untyped
39
+ def endpoint_model_class: (untyped) -> untyped
40
+ end
41
+ end
@@ -0,0 +1,46 @@
1
+ # Generated from lib/paper_trail_diff/activity_collection_event_applier.rb with RBS::Inline
2
+
3
+ module PaperTrailDiff
4
+ # Applies a safe collection event across every selected route for its record type.
5
+ class ActivityCollectionEventApplier
6
+ # : (record_resolver: ActivityEventRecordResolver, record_normalizer: ActivityEventRecordNormalizer, route_updater: ActivityCollectionRouteUpdater, relationship: ActivityRelationship) -> void
7
+ def initialize: (record_resolver: ActivityEventRecordResolver, record_normalizer: ActivityEventRecordNormalizer, route_updater: ActivityCollectionRouteUpdater, relationship: ActivityRelationship) -> void
8
+
9
+ # : (Array[Array[untyped]], untyped, ActivitySnapshotDelta?) -> bool
10
+ def safe?: (Array[Array[untyped]], untyped, ActivitySnapshotDelta?) -> bool
11
+
12
+ # : (untyped, untyped, RecordSnapshot, SnapshotNormalizer, Array[Array[untyped]], untyped, ActivitySnapshotDelta?) -> [bool, RecordSnapshot]
13
+ def call: (untyped, untyped, RecordSnapshot, SnapshotNormalizer, Array[Array[untyped]], untyped, ActivitySnapshotDelta?) -> [ bool, RecordSnapshot ]
14
+
15
+ private
16
+
17
+ @record_normalizer: ActivityEventRecordNormalizer
18
+
19
+ @record_resolver: ActivityEventRecordResolver
20
+
21
+ @relationship: ActivityRelationship
22
+
23
+ @route_updater: ActivityCollectionRouteUpdater
24
+
25
+ # : (RecordSnapshot, Array[untyped], untyped, ActivitySnapshotDelta?, Array[untyped], SnapshotNormalizer, Array[untyped]) -> RecordSnapshot
26
+ def apply_route: (RecordSnapshot, Array[untyped], untyped, ActivitySnapshotDelta?, Array[untyped], SnapshotNormalizer, Array[untyped]) -> RecordSnapshot
27
+
28
+ # : (Array[Array[untyped]], untyped) -> bool
29
+ def unsafe_through_membership_event?: (Array[Array[untyped]], untyped) -> bool
30
+
31
+ # : (Array[Array[untyped]], ActivitySnapshotDelta?) -> bool
32
+ def unsafe_nested_membership_delta?: (Array[Array[untyped]], ActivitySnapshotDelta?) -> bool
33
+
34
+ # : (RecordSnapshot, Array[untyped], untyped, ActivitySnapshotDelta?, Array[untyped], SnapshotNormalizer, Array[untyped]) -> [untyped, RecordSnapshot?]
35
+ def route_event_state: (RecordSnapshot, Array[untyped], untyped, ActivitySnapshotDelta?, Array[untyped], SnapshotNormalizer, Array[untyped]) -> [ untyped, RecordSnapshot? ]
36
+
37
+ # : (untyped, Array[untyped], SnapshotNormalizer, Array[untyped]) -> RecordSnapshot?
38
+ def normalized_event_record: (untyped, Array[untyped], SnapshotNormalizer, Array[untyped]) -> RecordSnapshot?
39
+
40
+ # : (RecordSnapshot, Array[untyped], untyped, ActivitySnapshotDelta?) -> RecordSnapshot?
41
+ def existing_delta_record: (RecordSnapshot, Array[untyped], untyped, ActivitySnapshotDelta?) -> RecordSnapshot?
42
+
43
+ # : (RecordSnapshot, Array[untyped], ActivitySnapshotDelta) -> RecordSnapshot?
44
+ def nested_delta_owner: (RecordSnapshot, Array[untyped], ActivitySnapshotDelta) -> RecordSnapshot?
45
+ end
46
+ end
@@ -0,0 +1,25 @@
1
+ # Generated from lib/paper_trail_diff/activity_collection_record_updater.rb with RBS::Inline
2
+
3
+ module PaperTrailDiff
4
+ # Applies one event to the leaf records of a collection association snapshot.
5
+ class ActivityCollectionRecordUpdater
6
+ # : (ActivityRelationship) -> void
7
+ def initialize: (ActivityRelationship) -> void
8
+
9
+ # : (AssociationSnapshot, ActivityCollectionRouteChange, untyped, RecordSnapshot) -> RecordSnapshot?
10
+ def event_child: (AssociationSnapshot, ActivityCollectionRouteChange, untyped, RecordSnapshot) -> RecordSnapshot?
11
+
12
+ # : (AssociationSnapshot, untyped, RecordSnapshot?) -> [Array[RecordSnapshot], RecordSnapshot?, RecordSnapshot?, bool]
13
+ def call: (AssociationSnapshot, untyped, RecordSnapshot?) -> [ Array[RecordSnapshot], RecordSnapshot?, RecordSnapshot?, bool ]
14
+
15
+ # : (untyped, RecordSnapshot?) -> String
16
+ def replacement_type: (untyped, RecordSnapshot?) -> String
17
+
18
+ private
19
+
20
+ @relationship: ActivityRelationship
21
+
22
+ # : (Array[RecordSnapshot], Integer?, RecordSnapshot?) -> Array[RecordSnapshot]
23
+ def replacement_records: (Array[RecordSnapshot], Integer?, RecordSnapshot?) -> Array[RecordSnapshot]
24
+ end
25
+ end
@@ -0,0 +1,17 @@
1
+ # Generated from lib/paper_trail_diff/activity_collection_route_change.rb with RBS::Inline
2
+
3
+ module PaperTrailDiff
4
+ # Carries one collection event through recursive immutable route replacement.
5
+ class ActivityCollectionRouteChange
6
+ attr_reader route: Array[untyped]
7
+
8
+ attr_reader version: untyped
9
+
10
+ attr_reader record: untyped
11
+
12
+ attr_reader replacement: RecordSnapshot?
13
+
14
+ # : (route: Array[untyped], version: untyped, record: untyped, replacement: RecordSnapshot?) -> void
15
+ def initialize: (route: Array[untyped], version: untyped, record: untyped, replacement: RecordSnapshot?) -> void
16
+ end
17
+ end
@@ -0,0 +1,44 @@
1
+ # Generated from lib/paper_trail_diff/activity_collection_route_updater.rb with RBS::Inline
2
+
3
+ module PaperTrailDiff
4
+ # Replaces a collection event record along one explicit immutable snapshot route.
5
+ class ActivityCollectionRouteUpdater
6
+ # : (pool: SnapshotPool, relationship: ActivityRelationship) -> void
7
+ def initialize: (pool: SnapshotPool, relationship: ActivityRelationship) -> void
8
+
9
+ # : (RecordSnapshot, ActivityCollectionRouteChange, ?depth: Integer) -> [RecordSnapshot, bool]
10
+ def call: (RecordSnapshot, ActivityCollectionRouteChange, ?depth: Integer) -> [ RecordSnapshot, bool ]
11
+
12
+ private
13
+
14
+ @pool: SnapshotPool
15
+
16
+ @record_updater: ActivityCollectionRecordUpdater
17
+
18
+ @relationship: ActivityRelationship
19
+
20
+ # : (AssociationSnapshot, RecordSnapshot, ActivityCollectionRouteChange, Integer) -> [Array[RecordSnapshot], RecordSnapshot?, RecordSnapshot?, bool, bool]
21
+ def updated_records: (AssociationSnapshot, RecordSnapshot, ActivityCollectionRouteChange, Integer) -> [ Array[RecordSnapshot], RecordSnapshot?, RecordSnapshot?, bool, bool ]
22
+
23
+ # : (AssociationSnapshot, RecordSnapshot, ActivityCollectionRouteChange) -> [Array[RecordSnapshot], RecordSnapshot?, RecordSnapshot?, bool, bool]
24
+ def leaf_records: (AssociationSnapshot, RecordSnapshot, ActivityCollectionRouteChange) -> [ Array[RecordSnapshot], RecordSnapshot?, RecordSnapshot?, bool, bool ]
25
+
26
+ # : (AssociationSnapshot, ActivityCollectionRouteChange, Integer) -> [Array[RecordSnapshot], RecordSnapshot?, RecordSnapshot?, bool]?
27
+ def targeted_parent: (AssociationSnapshot, ActivityCollectionRouteChange, Integer) -> [ Array[RecordSnapshot], RecordSnapshot?, RecordSnapshot?, bool ]?
28
+
29
+ # : (AssociationSnapshot, ActivityCollectionRouteChange, Integer) -> [Array[RecordSnapshot], RecordSnapshot?, RecordSnapshot?, bool, bool]
30
+ def recursive_records: (AssociationSnapshot, ActivityCollectionRouteChange, Integer) -> [ Array[RecordSnapshot], RecordSnapshot?, RecordSnapshot?, bool, bool ]
31
+
32
+ # : ([RecordSnapshot?, RecordSnapshot?, bool], RecordSnapshot, RecordSnapshot, bool) -> [RecordSnapshot?, RecordSnapshot?, bool]
33
+ def recursive_transition: ([ RecordSnapshot?, RecordSnapshot?, bool ], RecordSnapshot, RecordSnapshot, bool) -> [ RecordSnapshot?, RecordSnapshot?, bool ]
34
+
35
+ # : (Array[RecordSnapshot], Integer, RecordSnapshot, RecordSnapshot, bool) -> [Array[RecordSnapshot], RecordSnapshot?, RecordSnapshot?, bool]
36
+ def targeted_parent_replacement: (Array[RecordSnapshot], Integer, RecordSnapshot, RecordSnapshot, bool) -> [ Array[RecordSnapshot], RecordSnapshot?, RecordSnapshot?, bool ]
37
+
38
+ # : (AssociationSnapshot, untyped, ActivityCollectionRouteChange) -> Integer?
39
+ def nested_owner_position: (AssociationSnapshot, untyped, ActivityCollectionRouteChange) -> Integer?
40
+
41
+ # : (RecordSnapshot, String, AssociationSnapshot) -> RecordSnapshot
42
+ def replace_association: (RecordSnapshot, String, AssociationSnapshot) -> RecordSnapshot
43
+ end
44
+ end
@@ -0,0 +1,19 @@
1
+ # Generated from lib/paper_trail_diff/activity_event_record_normalizer.rb with RBS::Inline
2
+
3
+ module PaperTrailDiff
4
+ # Normalizes one event record with the historical reader for its boundary.
5
+ class ActivityEventRecordNormalizer
6
+ # : (?association_reader: untyped) -> void
7
+ def initialize: (?association_reader: untyped) -> void
8
+
9
+ # : (untyped, reflection: untyped, subtree: AssociationTree, path: String, normalizer: SnapshotNormalizer, root_endpoint: untyped, context_endpoint: untyped) -> RecordSnapshot?
10
+ def call: (untyped, reflection: untyped, subtree: AssociationTree, path: String, normalizer: SnapshotNormalizer, root_endpoint: untyped, context_endpoint: untyped) -> RecordSnapshot?
11
+
12
+ private
13
+
14
+ @association_reader: untyped
15
+
16
+ # : (untyped, habtm_version: untyped) -> HistoricalAssociationReifier
17
+ def historical_reader: (untyped, habtm_version: untyped) -> HistoricalAssociationReifier
18
+ end
19
+ end
@@ -0,0 +1,44 @@
1
+ # Generated from lib/paper_trail_diff/activity_event_record_resolver.rb with RBS::Inline
2
+
3
+ module PaperTrailDiff
4
+ # Reconstructs an event's post-change record or immutable scalar delta.
5
+ class ActivityEventRecordResolver
6
+ RECORD_AFTER_HANDLERS: untyped
7
+
8
+ # : (?record_transition: untyped) -> void
9
+ def initialize: (?record_transition: untyped) -> void
10
+
11
+ # : (untyped) -> untyped
12
+ def record_after: (untyped) -> untyped
13
+
14
+ # : (untyped) -> ActivitySnapshotDelta?
15
+ def snapshot_delta: (untyped) -> ActivitySnapshotDelta?
16
+
17
+ # : (untyped) -> untyped
18
+ def changed_record_after: (untyped) -> untyped
19
+
20
+ # : (untyped) -> untyped
21
+ def created_record_after: (untyped) -> untyped
22
+
23
+ # : (untyped) -> untyped
24
+ def updated_record_after: (untyped) -> untyped
25
+
26
+ # Mirrors PaperTrail's changeset deserialization without resolving
27
+ # +version.item+, which would issue one live-record query per event.
28
+ # : (untyped, untyped) -> untyped
29
+ def deserialized_changeset: (untyped, untyped) -> untyped
30
+
31
+ private
32
+
33
+ @record_transition: untyped
34
+
35
+ # : (untyped, untyped) -> Hash[untyped, untyped]
36
+ def after_attributes: (untyped, untyped) -> Hash[untyped, untyped]
37
+
38
+ # : (untyped, untyped) -> untyped
39
+ def apply_changes: (untyped, untyped) -> untyped
40
+
41
+ # : (untyped, untyped, untyped) -> untyped
42
+ def standard_changeset: (untyped, untyped, untyped) -> untyped
43
+ end
44
+ end
@@ -0,0 +1,54 @@
1
+ # Generated from lib/paper_trail_diff/activity_event_route_finder.rb with RBS::Inline
2
+
3
+ module PaperTrailDiff
4
+ # Finds explicitly selected collection and belongs-to routes for one event type.
5
+ class ActivityEventRouteFinder
6
+ # : (AssociationTraversal) -> void
7
+ def initialize: (AssociationTraversal) -> void
8
+
9
+ # : (untyped, AssociationTree, String, ?path: String) -> Array[Array[untyped]]
10
+ def collection_routes: (untyped, AssociationTree, String, ?path: String) -> Array[Array[untyped]]
11
+
12
+ # : (untyped, AssociationTree, String, ?path: String) -> Array[Array[untyped]]
13
+ def belongs_to_routes: (untyped, AssociationTree, String, ?path: String) -> Array[Array[untyped]]
14
+
15
+ private
16
+
17
+ @belongs_to_model: untyped
18
+
19
+ @belongs_to_path: String?
20
+
21
+ @belongs_to_routes: Array[Array[untyped]]?
22
+
23
+ @belongs_to_tree: AssociationTree?
24
+
25
+ @belongs_to_type: String?
26
+
27
+ @collection_model: untyped
28
+
29
+ @collection_path: String?
30
+
31
+ @collection_routes: Array[Array[untyped]]?
32
+
33
+ @collection_tree: AssociationTree?
34
+
35
+ @collection_type: String?
36
+
37
+ @traversal: AssociationTraversal
38
+
39
+ # : (Array[Array[untyped]]) -> Array[Array[untyped]]
40
+ def freeze_routes: (Array[Array[untyped]]) -> Array[Array[untyped]]
41
+
42
+ # : (untyped, AssociationTree, String, Symbol, path: String) -> Array[Array[untyped]]
43
+ def routes: (untyped, AssociationTree, String, Symbol, path: String) -> Array[Array[untyped]]
44
+
45
+ # : (untyped, AssociationTree, String, Symbol, String) -> Array[Array[untyped]]
46
+ def routes_for_reflection: (untyped, AssociationTree, String, Symbol, String) -> Array[Array[untyped]]
47
+
48
+ # : (untyped, String, Symbol) -> bool
49
+ def direct_route?: (untyped, String, Symbol) -> bool
50
+
51
+ # : (untyped, Symbol) -> bool
52
+ def supported_direct_reflection?: (untyped, Symbol) -> bool
53
+ end
54
+ end
@@ -1,138 +1,46 @@
1
1
  # Generated from lib/paper_trail_diff/activity_event_snapshot_refresher.rb with RBS::Inline
2
2
 
3
3
  module PaperTrailDiff
4
- # Applies safe descendant event deltas without rebuilding an entire selected branch.
5
- # rubocop:disable Metrics/ClassLength
4
+ # Dispatches safe descendant events to focused immutable snapshot appliers.
6
5
  class ActivityEventSnapshotRefresher
7
- RECORD_AFTER_HANDLERS: untyped
8
-
9
6
  # : (traversal: AssociationTraversal, pool: SnapshotPool, components: untyped, ?association_reader: untyped, ?record_transition: untyped) -> void
10
7
  def initialize: (traversal: AssociationTraversal, pool: SnapshotPool, components: untyped, ?association_reader: untyped, ?record_transition: untyped) -> void
11
8
 
12
- # : (untyped, untyped, RecordSnapshot, Array[String], ActivityEvent?) -> [bool, RecordSnapshot?]
13
- def call: (untyped, untyped, RecordSnapshot, Array[String], ActivityEvent?) -> [ bool, RecordSnapshot? ]
14
-
15
- private
16
-
17
- @association_reader: untyped
18
-
19
- @components: untyped
20
-
21
- @pool: SnapshotPool
22
-
23
- @record_transition: untyped
24
-
25
- @traversal: AssociationTraversal
9
+ # : (SnapshotPool, untyped) -> void
10
+ def configure_appliers: (SnapshotPool, untyped) -> void
26
11
 
27
- # : (Array[Array[untyped]], untyped) -> bool
28
- def unsafe_through_membership_event?: (Array[Array[untyped]], untyped) -> bool
12
+ # : (SnapshotPool) -> ActivityCollectionRouteUpdater
13
+ def collection_updater: (SnapshotPool) -> ActivityCollectionRouteUpdater
29
14
 
30
- # : (Array[Array[untyped]], ActivitySnapshotDelta?) -> bool
31
- def unsafe_nested_membership_delta?: (Array[Array[untyped]], ActivitySnapshotDelta?) -> bool
15
+ # : (ActivityEventRecordNormalizer, ActivityCollectionRouteUpdater) -> ActivityCollectionEventApplier
16
+ def collection_applier: (ActivityEventRecordNormalizer, ActivityCollectionRouteUpdater) -> ActivityCollectionEventApplier
32
17
 
33
- # : (untyped, untyped, RecordSnapshot, SnapshotNormalizer, Array[Array[untyped]], untyped, ActivitySnapshotDelta?) -> [bool, RecordSnapshot]
34
- def collection_target_snapshot: (untyped, untyped, RecordSnapshot, SnapshotNormalizer, Array[Array[untyped]], untyped, ActivitySnapshotDelta?) -> [ bool, RecordSnapshot ]
18
+ # : (ActivityEventRecordNormalizer) -> ActivityBelongsToEventApplier
19
+ def belongs_to_applier: (ActivityEventRecordNormalizer) -> ActivityBelongsToEventApplier
35
20
 
36
- # : (RecordSnapshot, Array[untyped], untyped, ActivitySnapshotDelta?, Array[untyped], SnapshotNormalizer, untyped, untyped) -> [untyped, RecordSnapshot?]
37
- def collection_route_event_state: (RecordSnapshot, Array[untyped], untyped, ActivitySnapshotDelta?, Array[untyped], SnapshotNormalizer, untyped, untyped) -> [ untyped, RecordSnapshot? ]
38
-
39
- # : (untyped, Array[untyped], SnapshotNormalizer, untyped, untyped) -> RecordSnapshot?
40
- def normalized_collection_event_record: (untyped, Array[untyped], SnapshotNormalizer, untyped, untyped) -> RecordSnapshot?
41
-
42
- # : (RecordSnapshot, Array[untyped], untyped, ActivitySnapshotDelta?) -> RecordSnapshot?
43
- def existing_delta_record: (RecordSnapshot, Array[untyped], untyped, ActivitySnapshotDelta?) -> RecordSnapshot?
44
-
45
- # : (RecordSnapshot, Array[untyped], ActivitySnapshotDelta) -> RecordSnapshot?
46
- def nested_delta_owner: (RecordSnapshot, Array[untyped], ActivitySnapshotDelta) -> RecordSnapshot?
47
-
48
- # : (untyped, AssociationTree, String, ?path: String) -> Array[Array[untyped]]
49
- def direct_collection_routes: (untyped, AssociationTree, String, ?path: String) -> Array[Array[untyped]]
50
-
51
- # : (RecordSnapshot, Array[untyped], untyped, untyped, RecordSnapshot?, ?depth: Integer) -> [RecordSnapshot, bool]
52
- def replace_collection_route: (RecordSnapshot, Array[untyped], untyped, untyped, RecordSnapshot?, ?depth: Integer) -> [ RecordSnapshot, bool ]
53
-
54
- # : (AssociationSnapshot, untyped, untyped, untyped, RecordSnapshot, RecordSnapshot?) -> RecordSnapshot?
55
- def collection_event_child: (AssociationSnapshot, untyped, untyped, untyped, RecordSnapshot, RecordSnapshot?) -> RecordSnapshot?
56
-
57
- # : (AssociationSnapshot, Array[untyped], untyped, untyped, RecordSnapshot?, Integer) -> [Array[RecordSnapshot], RecordSnapshot?, RecordSnapshot?, bool]?
58
- def replace_targeted_collection_parent: (AssociationSnapshot, Array[untyped], untyped, untyped, RecordSnapshot?, Integer) -> [ Array[RecordSnapshot], RecordSnapshot?, RecordSnapshot?, bool ]?
21
+ # : (untyped, untyped, RecordSnapshot, Array[String], ActivityEvent?) -> [bool, RecordSnapshot?]
22
+ def call: (untyped, untyped, RecordSnapshot, Array[String], ActivityEvent?) -> [ bool, RecordSnapshot? ]
59
23
 
60
- # : (Array[RecordSnapshot], Integer, RecordSnapshot, RecordSnapshot, bool) -> [Array[RecordSnapshot], RecordSnapshot?, RecordSnapshot?, bool]
61
- def targeted_parent_replacement: (Array[RecordSnapshot], Integer, RecordSnapshot, RecordSnapshot, bool) -> [ Array[RecordSnapshot], RecordSnapshot?, RecordSnapshot?, bool ]
24
+ private
62
25
 
63
- # : (AssociationSnapshot, untyped, untyped, untyped) -> Integer?
64
- def nested_owner_position: (AssociationSnapshot, untyped, untyped, untyped) -> Integer?
26
+ @belongs_to_applier: ActivityBelongsToEventApplier
65
27
 
66
- # : (untyped, untyped, RecordSnapshot, AssociationTree, SnapshotNormalizer, untyped) -> [bool, RecordSnapshot?]
67
- def belongs_to_target_snapshot: (untyped, untyped, RecordSnapshot, AssociationTree, SnapshotNormalizer, untyped) -> [ bool, RecordSnapshot? ]
28
+ @collection_applier: ActivityCollectionEventApplier
68
29
 
69
- # : (untyped, AssociationTree, String, ?path: String) -> Array[Array[untyped]]
70
- def belongs_to_routes: (untyped, AssociationTree, String, ?path: String) -> Array[Array[untyped]]
30
+ @components: untyped
71
31
 
72
- # : (Array[untyped], untyped, SnapshotNormalizer, untyped, untyped) -> RecordSnapshot?
73
- def normalized_route_record: (Array[untyped], untyped, SnapshotNormalizer, untyped, untyped) -> RecordSnapshot?
32
+ @record_resolver: ActivityEventRecordResolver
74
33
 
75
- # : (RecordSnapshot, Array[untyped], untyped, RecordSnapshot?, ?depth: Integer) -> [RecordSnapshot, bool]
76
- def replace_route: (RecordSnapshot, Array[untyped], untyped, RecordSnapshot?, ?depth: Integer) -> [ RecordSnapshot, bool ]
34
+ @relationship: ActivityRelationship
77
35
 
78
- # : (Array[RecordSnapshot], untyped, RecordSnapshot?) -> Array[RecordSnapshot]
79
- def replace_existing_target: (Array[RecordSnapshot], untyped, RecordSnapshot?) -> Array[RecordSnapshot]
36
+ @route_finder: ActivityEventRouteFinder
80
37
 
81
38
  # : (untyped) -> untyped
82
39
  def record_after: (untyped) -> untyped
83
40
 
84
- # PaperTrail create/update versions contain deserialized change pairs, so
85
- # their post-event records need no successor query.
86
- # : (untyped) -> untyped
87
- def changed_record_after: (untyped) -> untyped
88
-
89
- # : (untyped) -> untyped
90
- def created_record_after: (untyped) -> untyped
91
-
92
- # : (untyped) -> untyped
93
- def updated_record_after: (untyped) -> untyped
94
-
95
- # : (untyped, untyped) -> Hash[untyped, untyped]
96
- def after_attributes: (untyped, untyped) -> Hash[untyped, untyped]
97
-
98
- # : (untyped, untyped) -> untyped
99
- def apply_changes: (untyped, untyped) -> untyped
100
-
101
- # Mirrors PaperTrail's changeset deserialization without resolving
102
- # +version.item+, which would issue one live-record query per event.
103
41
  # : (untyped, untyped) -> untyped
104
42
  def deserialized_changeset: (untyped, untyped) -> untyped
105
43
 
106
- # : (untyped, untyped, untyped) -> untyped
107
- def standard_changeset: (untyped, untyped, untyped) -> untyped
108
-
109
- # : (untyped) -> ActivitySnapshotDelta?
110
- def activity_snapshot_delta: (untyped) -> ActivitySnapshotDelta?
111
-
112
- # : (untyped, untyped, RecordSnapshot, ?state: Symbol) -> bool
113
- def member_of_owner?: (untyped, untyped, RecordSnapshot, ?state: Symbol) -> bool
114
-
115
- # : (untyped, untyped, state: Symbol) -> untyped
116
- def event_attribute: (untyped, untyped, state: Symbol) -> untyped
117
-
118
- # : (untyped, untyped, state: Symbol) -> untyped
119
- def relationship_owner_id: (untyped, untyped, state: Symbol) -> untyped
120
-
121
- # : (untyped, untyped, AssociationTree, String, SnapshotNormalizer, untyped, untyped) -> RecordSnapshot?
122
- def normalize_event_record: (untyped, untyped, AssociationTree, String, SnapshotNormalizer, untyped, untyped) -> RecordSnapshot?
123
-
124
- # : (untyped, habtm_version: untyped) -> HistoricalAssociationReifier
125
- def historical_reader: (untyped, habtm_version: untyped) -> HistoricalAssociationReifier
126
-
127
- # : (AssociationSnapshot, untyped, RecordSnapshot?) -> [Array[RecordSnapshot], RecordSnapshot?, RecordSnapshot?, bool]
128
- def replace_collection_record: (AssociationSnapshot, untyped, RecordSnapshot?) -> [ Array[RecordSnapshot], RecordSnapshot?, RecordSnapshot?, bool ]
129
-
130
- # : (Array[RecordSnapshot], Integer?, RecordSnapshot?) -> Array[RecordSnapshot]
131
- def replacement_collection_records: (Array[RecordSnapshot], Integer?, RecordSnapshot?) -> Array[RecordSnapshot]
132
-
133
- # : (untyped, RecordSnapshot?) -> String
134
- def replacement_type: (untyped, RecordSnapshot?) -> String
135
-
136
44
  # : (untyped) -> untyped
137
45
  def endpoint_model_class: (untyped) -> untyped
138
46
  end
@@ -0,0 +1,23 @@
1
+ # Generated from lib/paper_trail_diff/activity_relationship.rb with RBS::Inline
2
+
3
+ module PaperTrailDiff
4
+ # Reads event-side foreign keys and matches them to an immutable snapshot owner.
5
+ class ActivityRelationship
6
+ # : (untyped, untyped, RecordSnapshot, ?state: Symbol) -> bool
7
+ def member_of_owner?: (untyped, untyped, RecordSnapshot, ?state: Symbol) -> bool
8
+
9
+ # : (untyped, untyped, state: Symbol) -> untyped
10
+ def owner_id: (untyped, untyped, state: Symbol) -> untyped
11
+
12
+ private
13
+
14
+ # : (untyped, untyped, state: Symbol) -> Array[String]
15
+ def relationship_owner_values: (untyped, untyped, state: Symbol) -> Array[String]
16
+
17
+ # : (untyped, untyped, state: Symbol) -> untyped
18
+ def event_attribute: (untyped, untyped, state: Symbol) -> untyped
19
+
20
+ # : (untyped, RecordSnapshot) -> Array[String]
21
+ def owner_types: (untyped, RecordSnapshot) -> Array[String]
22
+ end
23
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paper_trail_diff
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Williams
@@ -43,12 +43,21 @@ files:
43
43
  - QUICKSTART.md
44
44
  - README.md
45
45
  - lib/paper_trail_diff.rb
46
+ - lib/paper_trail_diff/activity_belongs_to_event_applier.rb
46
47
  - lib/paper_trail_diff/activity_boundary.rb
47
48
  - lib/paper_trail_diff/activity_child_candidate_loader.rb
49
+ - lib/paper_trail_diff/activity_collection_event_applier.rb
50
+ - lib/paper_trail_diff/activity_collection_record_updater.rb
51
+ - lib/paper_trail_diff/activity_collection_route_change.rb
52
+ - lib/paper_trail_diff/activity_collection_route_updater.rb
48
53
  - lib/paper_trail_diff/activity_event.rb
54
+ - lib/paper_trail_diff/activity_event_record_normalizer.rb
55
+ - lib/paper_trail_diff/activity_event_record_resolver.rb
56
+ - lib/paper_trail_diff/activity_event_route_finder.rb
49
57
  - lib/paper_trail_diff/activity_event_snapshot_refresher.rb
50
58
  - lib/paper_trail_diff/activity_history.rb
51
59
  - lib/paper_trail_diff/activity_range.rb
60
+ - lib/paper_trail_diff/activity_relationship.rb
52
61
  - lib/paper_trail_diff/activity_root_snapshot_refresher.rb
53
62
  - lib/paper_trail_diff/activity_snapshot_delta.rb
54
63
  - lib/paper_trail_diff/activity_snapshot_sequence.rb
@@ -101,12 +110,21 @@ files:
101
110
  - lib/paper_trail_diff/version_association_candidate_scope.rb
102
111
  - lib/paper_trail_diff/version_range.rb
103
112
  - sig/generated/paper_trail_diff.rbs
113
+ - sig/generated/paper_trail_diff/activity_belongs_to_event_applier.rbs
104
114
  - sig/generated/paper_trail_diff/activity_boundary.rbs
105
115
  - sig/generated/paper_trail_diff/activity_child_candidate_loader.rbs
116
+ - sig/generated/paper_trail_diff/activity_collection_event_applier.rbs
117
+ - sig/generated/paper_trail_diff/activity_collection_record_updater.rbs
118
+ - sig/generated/paper_trail_diff/activity_collection_route_change.rbs
119
+ - sig/generated/paper_trail_diff/activity_collection_route_updater.rbs
106
120
  - sig/generated/paper_trail_diff/activity_event.rbs
121
+ - sig/generated/paper_trail_diff/activity_event_record_normalizer.rbs
122
+ - sig/generated/paper_trail_diff/activity_event_record_resolver.rbs
123
+ - sig/generated/paper_trail_diff/activity_event_route_finder.rbs
107
124
  - sig/generated/paper_trail_diff/activity_event_snapshot_refresher.rbs
108
125
  - sig/generated/paper_trail_diff/activity_history.rbs
109
126
  - sig/generated/paper_trail_diff/activity_range.rbs
127
+ - sig/generated/paper_trail_diff/activity_relationship.rbs
110
128
  - sig/generated/paper_trail_diff/activity_root_snapshot_refresher.rbs
111
129
  - sig/generated/paper_trail_diff/activity_snapshot_delta.rbs
112
130
  - sig/generated/paper_trail_diff/activity_snapshot_sequence.rbs
@@ -164,11 +182,11 @@ licenses:
164
182
  metadata:
165
183
  allowed_push_host: https://rubygems.org
166
184
  bug_tracker_uri: https://github.com/aheathwilliams/paper_trail_diff/issues
167
- changelog_uri: https://github.com/aheathwilliams/paper_trail_diff/blob/v0.3.0/CHANGELOG.md
168
- documentation_uri: https://github.com/aheathwilliams/paper_trail_diff/blob/v0.3.0/README.md
185
+ changelog_uri: https://github.com/aheathwilliams/paper_trail_diff/blob/v0.3.1/CHANGELOG.md
186
+ documentation_uri: https://github.com/aheathwilliams/paper_trail_diff/blob/v0.3.1/README.md
169
187
  homepage_uri: https://github.com/aheathwilliams/paper_trail_diff
170
188
  rubygems_mfa_required: 'true'
171
- source_code_uri: https://github.com/aheathwilliams/paper_trail_diff/tree/v0.3.0
189
+ source_code_uri: https://github.com/aheathwilliams/paper_trail_diff/tree/v0.3.1
172
190
  rdoc_options: []
173
191
  require_paths:
174
192
  - lib