servactory 2.4.1 → 2.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 39039d8976222bae22b66ec4ee41d231a5ec589509bd32e15c717b0ef6c89d19
4
- data.tar.gz: 8c4de62f3d586fc7d767d17cd6918b30e7a0521e2bb01e3ed5f69e34b26694db
3
+ metadata.gz: 326823cbdccc9f0f3dfca48c5b2ddbf518d50a713c45280b19da21ddf4483907
4
+ data.tar.gz: ebf05e0ebdd4b9941809137d3f1e092ac72560fc199689d91713c253edcb3cd1
5
5
  SHA512:
6
- metadata.gz: b062e9ceeb16e47ee61133fccda32d8bca81e57424e76a849d7cdf9fb3491016a4a2ca61675142319a11f1286d9bdcc9388db5c4069d8d434df3ab827adc1124
7
- data.tar.gz: fdd074ac75c620cfdd41a5fb6173d83b7d87835d0bf1a572bf5e815e7f1db028312a6b7afc91c19ad06208917318afe884a87de64685853868c6dea57ab3ff57
6
+ metadata.gz: b99933c23fd601a8e5164a425695799b94648da7ba02232a676938f00466ce8bc60ecc59db4257f3d9e1b60ba98dbabb3f021bfbff263c085fe7c800c0b47976
7
+ data.tar.gz: db16a9b4bbdfcfa4fdd11c6eabf8ae45468c8989d34ddc6a268df17e29e68878c5be9db72fda4a5e07529d2a6ccd3a9e2a1a2eb73b60389e9bd9fd637b894a56
@@ -22,7 +22,7 @@ module Servactory
22
22
  rescue config.success_class => e
23
23
  Servactory::Result.success_for(context: e.context)
24
24
  rescue config.failure_class => e
25
- Servactory::Result.failure_for(exception: e)
25
+ Servactory::Result.failure_for(context: context, exception: e)
26
26
  end
27
27
 
28
28
  private
@@ -9,6 +9,18 @@ module Servactory
9
9
  define_singleton_method(key) { value }
10
10
  end
11
11
  end
12
+
13
+ def inspect
14
+ "#<#{self.class.name} #{draw_result}>"
15
+ end
16
+
17
+ private
18
+
19
+ def draw_result
20
+ methods(false).sort.map do |method_name|
21
+ "@#{method_name}=#{send(method_name)}"
22
+ end.join(", ")
23
+ end
12
24
  end
13
25
 
14
26
  private_constant :Outputs
@@ -19,11 +31,11 @@ module Servactory
19
31
  new(context: context).send(:as_success)
20
32
  end
21
33
 
22
- def self.failure_for(exception:)
23
- new(exception: exception).send(:as_failure)
34
+ def self.failure_for(context:, exception:)
35
+ new(context: context, exception: exception).send(:as_failure)
24
36
  end
25
37
 
26
- def initialize(context: nil, exception: nil)
38
+ def initialize(context:, exception: nil)
27
39
  @context = context
28
40
  @exception = exception
29
41
  end
@@ -39,7 +51,7 @@ module Servactory
39
51
  end
40
52
 
41
53
  def on_failure(type = :all)
42
- yield(exception: @exception) if failure? && [:all, @exception&.type].include?(type)
54
+ yield(outputs: outputs, exception: @exception) if failure? && [:all, @exception&.type].include?(type)
43
55
 
44
56
  self
45
57
  end
@@ -78,6 +90,10 @@ module Servactory
78
90
  false
79
91
  end
80
92
 
93
+ outputs.methods(false).each do |method_name|
94
+ define_singleton_method(method_name) { outputs.send(method_name) }
95
+ end
96
+
81
97
  self
82
98
  end
83
99
 
@@ -7,8 +7,8 @@ module Servactory
7
7
  Servactory::Result.success_for(context: new(attributes))
8
8
  end
9
9
 
10
- def self.as_failure(exception: nil)
11
- Servactory::Result.failure_for(exception: exception)
10
+ def self.as_failure(attributes = {}, exception: nil)
11
+ Servactory::Result.failure_for(context: new(attributes), exception: exception)
12
12
  end
13
13
 
14
14
  def initialize(attributes = {})
@@ -4,7 +4,7 @@ module Servactory
4
4
  module VERSION
5
5
  MAJOR = 2
6
6
  MINOR = 4
7
- PATCH = 1
7
+ PATCH = 3
8
8
  PRE = nil
9
9
 
10
10
  STRING = [MAJOR, MINOR, PATCH, PRE].compact.join(".")
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: servactory
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.1
4
+ version: 2.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anton Sokolov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-03-26 00:00:00.000000000 Z
11
+ date: 2024-03-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport