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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6417ca32463b2238feac9aa24170c153021e633e
4
- data.tar.gz: a4564955bfddf1646bbfc568b5f9c42bcd278577
3
+ metadata.gz: 04c7c5923e0df01f77bf06e4ad48c8a68e867c2d
4
+ data.tar.gz: bd0d9c4778cb50a9ce41106670b1487981883eae
5
5
  SHA512:
6
- metadata.gz: 98fe66a88f401bdc96b3ea91ac978574d7ddcb36a9522b72022576918be42468d066d84816f4f72c8b258bf5427632c9e5d896abdb2d30455afbc80e473eedf1
7
- data.tar.gz: a10caa1bd73859737e580d93e2fc200b3c086ce2a12dfa033ce07c4be084ae37565f4d7d3547ddec240bb4e01599734d920b111bca55dc21672cb682f71fb1fa
6
+ metadata.gz: 3e3c61af2b63770e0357e21879cb97025b114a0c806af94c97b237494348961c462662927ca3a1f4e93a11c2879d6664caf3e74b8416ce41fe603848ba9a2692
7
+ data.tar.gz: 4dc91c86e0c5a727df8b57bbbe5de8373890e57ab98c357f2792a9f9a6aad3d435f1d515f00211462afc61d6b849a421e2418631ead780a204907f0a65a7501f
@@ -23,14 +23,30 @@ module Corraios
23
23
 
24
24
  def merge!(other)
25
25
  raise CorraiosError unless self == other
26
- @value += other.value
27
- @deadline = [@deadline, other.deadline].max
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'])
@@ -1,3 +1,3 @@
1
1
  module Corraios
2
- VERSION = "0.0.9"
2
+ VERSION = "0.0.10"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: corraios
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rodrigo Ra