http_store 0.3.4 → 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/db/migrate/1_create_http_logs.rb +1 -0
- data/lib/http_store/client.rb +1 -1
- data/lib/http_store/helpers/storable.rb +21 -2
- data/lib/http_store/http_log.rb +3 -0
- data/lib/http_store/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2bb337e2004a6a150a320fd1a9d3afbe17054860faa48cb31b53f1f266382928
|
4
|
+
data.tar.gz: ca53ded6e7fbf4eaaa341b52a520a4d7b07b94322c87ce8ecf2e4ea4dc8542c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa430ae04cd59ba0aa5f2806815837f1322482019008d4f222830fd73ba51cbb2a9fd1f6f0da5fda10add07f594fbcbe39e3d8cb15aee9a534f80a08b6b6c2e8
|
7
|
+
data.tar.gz: 70d4a2cd9cb8cba4c0e7d331bad2466f2b06d60917ca90ed7e4fa156782400a3d23508b4b7a5e770ad480fbcf03cbbcc78152708eae73060d4da6dcb2a4a8e36
|
data/Gemfile.lock
CHANGED
data/lib/http_store/client.rb
CHANGED
@@ -17,7 +17,7 @@ module HttpStore
|
|
17
17
|
return unless request_valid?
|
18
18
|
|
19
19
|
# exist request or not force, return
|
20
|
-
return if !force && storeable_record.present?
|
20
|
+
load_storeable_record and return if !force && storeable_record.present?
|
21
21
|
|
22
22
|
execute # send request
|
23
23
|
raise HttpStore::RequestError, 'response_obj is nil' if response_obj.nil?
|
@@ -6,14 +6,29 @@ module HttpStore
|
|
6
6
|
def storeable_record
|
7
7
|
return unless HttpStore.config.store_enable
|
8
8
|
|
9
|
-
@
|
9
|
+
@storeable_record ||= HttpStore.config.store_class.find_by(request_digest: request_digest, response_valid: true)
|
10
|
+
end
|
11
|
+
|
12
|
+
def load_storeable_record
|
13
|
+
return if storeable_record.nil?
|
14
|
+
|
15
|
+
attrs =
|
16
|
+
storeable_record.attributes.slice(*HttpStore::ALL_KEYS).map do |k, v|
|
17
|
+
[k, v.is_a?(String) ? re_storable(v) : v]
|
18
|
+
end.to_h
|
19
|
+
|
20
|
+
@meta.parent_id = storeable_record.id
|
21
|
+
@meta.reverse_merge! attrs
|
10
22
|
end
|
11
23
|
|
12
24
|
# you can rewrite this callback, to store the request
|
13
25
|
def store_request
|
14
26
|
return unless HttpStore.config.store_enable
|
15
27
|
|
16
|
-
|
28
|
+
@parent_storeable_record = storeable_record
|
29
|
+
@storeable_record = HttpStore.config.store_class.new(storable_meta)
|
30
|
+
@storeable_record.parent = @parent_storeable_record if @parent_storeable_record.present?
|
31
|
+
save!
|
17
32
|
end
|
18
33
|
|
19
34
|
def storable_meta
|
@@ -26,6 +41,10 @@ module HttpStore
|
|
26
41
|
end.to_h
|
27
42
|
end
|
28
43
|
|
44
|
+
def re_storable(value)
|
45
|
+
|
46
|
+
end
|
47
|
+
|
29
48
|
def storable(value)
|
30
49
|
case value
|
31
50
|
when Hash
|
data/lib/http_store/http_log.rb
CHANGED
data/lib/http_store/version.rb
CHANGED