Skip to content

Commit

Permalink
Add readme section on diffing versions
Browse files Browse the repository at this point in the history
  • Loading branch information
westonganger committed Nov 12, 2024
1 parent 17192d5 commit 12fa8ce
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,19 @@ reified_parent, reified_children_hash = snapshot.fetch_reified_items
reified_children_hash.first.instance_variable_set("@readonly", false)
```

# Diffing Versions

We dont provide anything special to handle the diff. You can use the following example code to generate your own diffs.

```ruby
old_attrs = post.snapshots.first!
new_attrs = post.attributes # or could be another snapshot

attrs_not_changed = old_attrs.to_a.intersection(new_attrs.to_a).to_h

attrs_changed = new_attrs.to_a - attrs_not_changed.to_a
```

# Key Models Provided & Additional Customizations

A key aspect of this library is its simplicity and small API. For major functionality customizations we encourage you to first delete this gem and then copy this gems code directly into your repository.
Expand Down

0 comments on commit 12fa8ce

Please sign in to comment.