service_pattern 0.0.7 → 0.0.8

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
  SHA256:
3
- metadata.gz: 77863da179021d925441d0bf4a64fe8756ce925c45262523e7e34ff35e03956b
4
- data.tar.gz: 815cac6f2393f6f92181a14fd311c565d63069e96c9aebc3827c315fa24d2832
3
+ metadata.gz: 8ba006abbb363e6e905b04bc28d034d3ce3500a1972569796b3a4535d399f2a5
4
+ data.tar.gz: d6843c0cba4fcfe46ea34dc4b7e650a9356566a4e4c6ce2703234a3f44b88ca9
5
5
  SHA512:
6
- metadata.gz: 370ba577ae9fc3a77746e518502c71d872e22ee49ddab016124c1c3105a48b8cc6667e22ea4f9369f4224b9de298c3ff04940031eb86aeb1e8d9f8890fcb0289
7
- data.tar.gz: a80e81f4419b97fa4721a747a180729484264635d4feff4edb572d5e4dabda6a11d86928d1ba5fb1fcf11c9bd94734d82c9449bce4c8ee7d762af3c5e47de19c
6
+ metadata.gz: 4f0069948ebd6189ab2915d74b5a5ef299a61628082b58f8913ec5224746322d4f354542b4ece26d8672d58b38668651bc95b1ab660b2e4cf55bbbb0d2130393
7
+ data.tar.gz: 1c5dc20138d2d26a3e3b2e93d292861fd981c4fe7afc2a984dc09e48fe46dfd51ac71bd7e9030507a5d4998ff93a9c03c897173a96ef594f2aa410fb524a6b64
@@ -2,7 +2,7 @@ class ServicePattern::Response
2
2
  attr_reader :errors, :result
3
3
 
4
4
  def initialize(errors: [], result: nil)
5
- @errors = errors
5
+ @errors = ServicePattern::Service.convert_errors(errors)
6
6
  @result = result
7
7
  @success = !errors || errors.empty?
8
8
  end
@@ -33,13 +33,16 @@ class ServicePattern::Service
33
33
  response.result
34
34
  end
35
35
 
36
- def self.fail!(errors)
36
+ def self.convert_errors(errors)
37
37
  errors = [errors] unless errors.is_a?(Array)
38
- errors = errors.map do |error|
38
+ errors.map do |error|
39
39
  error = ServicePattern::FailError.new(message: error) unless error.is_a?(ServicePattern::FailError)
40
40
  error
41
41
  end
42
+ end
42
43
 
44
+ def self.fail!(errors)
45
+ errors = convert_errors(errors)
43
46
  error_messages = errors.map(&:message)
44
47
 
45
48
  error = ServicePattern::FailedError.new(error_messages.join(". "))
@@ -1,3 +1,3 @@
1
1
  module ServicePattern
2
- VERSION = "0.0.7".freeze
2
+ VERSION = "0.0.8".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: service_pattern
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - kaspernj
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-02 00:00:00.000000000 Z
11
+ date: 2020-09-03 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: ServicePattern for Ruby on Rails.
14
14
  email: