snapshotable 0.1.1 → 0.1.2

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
  SHA1:
3
- metadata.gz: b09d5b3092f500fd390a14910fab5c81dca8e0a2
4
- data.tar.gz: b94736fc88d7b25a84cce4b4e56a7205e9720bc8
3
+ metadata.gz: 6de38e7ae9020d6c1bd962cf5251f86cd393ea92
4
+ data.tar.gz: 48d422d6c78f0e6b02bd32905a399be113fd069d
5
5
  SHA512:
6
- metadata.gz: 91ed83cf0aaa5857c4d38a7e9703cc91747b529778db783db2b6ebd84a3f91b14b504d059e9a0f53a294f8660ef9355cde72e36fc45b650aba5b9b923b9cbe00
7
- data.tar.gz: 285028e088d072558e60d8f36f009c0c0eec0b83c6c917f72939f4812f84172baa4ef9348fb22ac257189561eda98d172f8b5901d7b5b238a8c533a0701f77ec
6
+ metadata.gz: adc30af44dc2f5abc99dc6526d822a429c66242b558499deae0810cee78b2d46acf25d0dddbdcb1885d62eb6426fa9e788055933b5695c69a6a49c5f054ad007
7
+ data.tar.gz: b1010103a1afcfba25b677894d42a079b57528685d6e878468abfd44ad4a8291ecc463cea593d379fdd59a53f336a617adbb13a26b4e44cc1e79ace5df39d3ae
@@ -29,9 +29,12 @@ module Snapshotable
29
29
  end
30
30
 
31
31
  module InstanceMethods
32
- def take_snapshot!
33
- snapshot = SnapshotCreator.new(self).call
34
- snapshot_class.create!(snapshot) if should_create_new_snapshot?(snapshot)
32
+ def take_snapshot!(force = false)
33
+ record = dup
34
+ record.id = id
35
+
36
+ snapshot = SnapshotCreator.new(record).call
37
+ snapshot_class.create!(snapshot) if force || should_create_new_snapshot?(snapshot)
35
38
  end
36
39
 
37
40
  def snapshots
@@ -86,10 +86,9 @@ module Snapshotable
86
86
  end
87
87
 
88
88
  def setup_callback(klass)
89
- klass.after_create do
90
- take_snapshot!
91
- clear_association_cache
92
- end
89
+ klass.after_create(
90
+ :take_snapshot!
91
+ )
93
92
  end
94
93
 
95
94
  def snapshot_class_name
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Snapshotable
4
- VERSION = '0.1.1'
4
+ VERSION = '0.1.2'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: snapshotable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - João Batista Marinho