corraios 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/corraios/delivery.rb +18 -2
- data/lib/corraios/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 04c7c5923e0df01f77bf06e4ad48c8a68e867c2d
|
4
|
+
data.tar.gz: bd0d9c4778cb50a9ce41106670b1487981883eae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e3c61af2b63770e0357e21879cb97025b114a0c806af94c97b237494348961c462662927ca3a1f4e93a11c2879d6664caf3e74b8416ce41fe603848ba9a2692
|
7
|
+
data.tar.gz: 4dc91c86e0c5a727df8b57bbbe5de8373890e57ab98c357f2792a9f9a6aad3d435f1d515f00211462afc61d6b849a421e2418631ead780a204907f0a65a7501f
|
data/lib/corraios/delivery.rb
CHANGED
@@ -23,14 +23,30 @@ module Corraios
|
|
23
23
|
|
24
24
|
def merge!(other)
|
25
25
|
raise CorraiosError unless self == other
|
26
|
-
|
27
|
-
|
26
|
+
if success? && other.success?
|
27
|
+
merge_when_success!(other)
|
28
|
+
else
|
29
|
+
merge_when_error!(other)
|
30
|
+
end
|
28
31
|
end
|
29
32
|
|
30
33
|
def ==(other)
|
31
34
|
@code == other.code
|
32
35
|
end
|
36
|
+
|
33
37
|
private
|
38
|
+
|
39
|
+
def merge_when_success!(other)
|
40
|
+
@value += other.value
|
41
|
+
@deadline = [@deadline, other.deadline].max
|
42
|
+
end
|
43
|
+
|
44
|
+
def merge_when_error!(other)
|
45
|
+
@value = 0.0
|
46
|
+
@deadline = 0
|
47
|
+
@error_message ||= other.error_message
|
48
|
+
end
|
49
|
+
|
34
50
|
def parse_response(response)
|
35
51
|
service = validate_response(response)
|
36
52
|
value = to_float(service['Valor'])
|
data/lib/corraios/version.rb
CHANGED