westonganger / active_snapshot

Simplified snapshots and restoration for ActiveRecord models and associations with a transparent white-box implementation
MIT License
103 stars 16 forks source link

Set implicit empty snapshot children #7

Closed pjmartorell closed 2 years ago

pjmartorell commented 2 years ago

Resolves https://github.com/westonganger/active_snapshot/issues/4

Now calling has_snapshot_children is optional as the documentation states and it will be set as an empty hash by default. Calling it will override the default.

After this change, the following condition will return always false, but I think it's okay to keep it just in case this default is removed in the future: https://github.com/westonganger/active_snapshot/blob/23a769fbe1f42adecbb81edf015a0c5fc518767d/lib/active_snapshot/models/concerns/snapshots_concern.rb#L41-L42

westonganger commented 2 years ago

I would rather change the method children_to_snapshot

https://github.com/westonganger/active_snapshot/blob/0635a42a681ff9b00842434f9f569faefee9920b/lib/active_snapshot/models/concerns/snapshots_concern.rb#L56

Change to return {}

pjmartorell commented 2 years ago

I would rather change the method children_to_snapshot

https://github.com/westonganger/active_snapshot/blob/0635a42a681ff9b00842434f9f569faefee9920b/lib/active_snapshot/models/concerns/snapshots_concern.rb#L56

Change to return {}

Yes, your suggestion makes more sense 👍

westonganger commented 2 years ago

v0.2.1 is now released which contains this fix.