cache-object 0.0.1 → 0.0.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: 7c71004d93363e44c125a123d5657588af9a31da
4
- data.tar.gz: 41b528c9d8fe6cf225ba47a1e68b8845936f9297
3
+ metadata.gz: b00384e28562fe8f44389c201a32090c1a8e1a11
4
+ data.tar.gz: 8f92dbcb480d43eaf062356bd31477d38f43c481
5
5
  SHA512:
6
- metadata.gz: 97ec547f05417382920b39bc0a4760d265f429e6825afc5ec0cb956bfc79ba76616d8c74937ee85072a2dc4e154bfb6e9ad48b5f46c4915a9ea902c49ee624df
7
- data.tar.gz: 6d7a334cfe0d6481369553a3ee7aec038e9f00c84b2ef20cfb346891fa6e1d56d85940561eab4496e77d58b670a718d008cb9edad1ac14a9d5b6c681f84368ae
6
+ metadata.gz: 0f8b87b32430f50a8095aadf5aaf56e51a9a05461d9e84de9fc67d186866ad94e821cf35853b23994f804cbd074eaeafe57e7095ff5d55e52c5e267072568d5a
7
+ data.tar.gz: e3acc42a006c8c8ac416b1474b98857ddf50d5ac3151d00297a36ccf9daf997aabf62b8b4c06112f984d9b88f1fdfe2b622679c9a53e03fa036c6792e31def93
@@ -17,6 +17,29 @@ module Cache
17
17
  end
18
18
  end
19
19
 
20
+ def _dump(level = 0)
21
+ Marshal.dump(attributes)
22
+ end
23
+
24
+ def load_from_cache(attributes)
25
+ attributes.each_pair do |key, value|
26
+ attributes[key] = value
27
+ end
28
+
29
+ @attributes = self.class.initialize_attributes(attributes)
30
+ @relation = nil
31
+
32
+ @attributes_cache, @previously_changed, @changed_attributes = {}, {}, {}
33
+ @association_cache = {}
34
+ @aggregation_cache = {}
35
+ @_start_transaction_state = {}
36
+ @readonly = @destroyed = @marked_for_destruction = false
37
+ @new_record = false
38
+ @column_types = self.class.column_types if self.class.respond_to?(:column_types)
39
+ @changed_attributes = {}
40
+ @new_record = false
41
+ end
42
+
20
43
  def write_cache!
21
44
  Cache::Object.adapter.write(_cache_object_decorator)
22
45
  end
@@ -30,6 +53,14 @@ module Cache
30
53
  end
31
54
 
32
55
  module ClassMethods
56
+ def _load(args)
57
+ attributes = Marshal.load(args)
58
+
59
+ object = allocate
60
+ object.load_from_cache(attributes)
61
+ object
62
+ end
63
+
33
64
  def find(*args)
34
65
  Cache::Object.adapter.fetch(self, *args[0]) do
35
66
  super(*args)
@@ -1,5 +1,5 @@
1
1
  module Cache
2
2
  module Object
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cache-object
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Camuto