servactory 2.4.0 → 2.4.2

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: 3996c6a138a1683fe3e46b04e9a57f9e135c93f3fd3855287374595e3b3111b3
4
- data.tar.gz: 72e31e10893e67f5fd57ce54f0241ac35720071d6b1837bda85a953e717c8ae5
3
+ metadata.gz: fbf66d2c89ef6a0b50a80343230e56d940e41ce3754528cc902dbf17663800a7
4
+ data.tar.gz: dc302908e1305c9b9cbecacf1506fe9222db5e9b835fd0e8febb6e54e1211b92
5
5
  SHA512:
6
- metadata.gz: ec9727d9cd881bfb898f6843488fe7676ba18746ae40fd88e6feb391352c2e6eebf89137ca7d0743577d92caadde20a673973268040c2482eece16af82db2d5b
7
- data.tar.gz: a73916a75bcd4b681ad41fc23ba63546d1a7ae46ff738eeb0f36671f191bd1195c64778e9ea7ddbec80a06c0c14dd46741b43bd521c09a94f9b6eb0cc395ab1f
6
+ metadata.gz: b9eb5b104b1ff966b92b2f656070379daf252d00921937383e094549bc3ae3a7782b6e43cbdec08051b38168a1d2d7f8e38d4b90e9c6a367828fd40c66218399
7
+ data.tar.gz: 2b51810de55de6b8a13ba4f7cc22e2ebd913839cd86fa68f05cec9c83b5558dbcba9bf13cf194f163287c5c7a0d7bab5bdf5a715b159106338611cc2d082c706
@@ -4,41 +4,29 @@ module Servactory
4
4
  module Context
5
5
  module Callable
6
6
  def call!(arguments = {})
7
- prepare_result_class
8
-
9
7
  context = send(:new)
10
8
 
11
9
  _call!(context, **arguments)
12
10
 
13
- self::Result.success_for(context: context)
11
+ Servactory::Result.success_for(context: context)
14
12
  rescue config.success_class => e
15
- self::Result.success_for(context: e.context)
13
+ Servactory::Result.success_for(context: e.context)
16
14
  end
17
15
 
18
16
  def call(arguments = {})
19
- prepare_result_class
20
-
21
17
  context = send(:new)
22
18
 
23
19
  _call!(context, **arguments)
24
20
 
25
- self::Result.success_for(context: context)
21
+ Servactory::Result.success_for(context: context)
26
22
  rescue config.success_class => e
27
- self::Result.success_for(context: e.context)
23
+ Servactory::Result.success_for(context: e.context)
28
24
  rescue config.failure_class => e
29
- self::Result.failure_for(exception: e)
25
+ Servactory::Result.failure_for(context: context, exception: e)
30
26
  end
31
27
 
32
28
  private
33
29
 
34
- def prepare_result_class
35
- return if Object.const_defined?("#{name}::Result")
36
-
37
- class_eval <<-RUBY, __FILE__, __LINE__ + 1
38
- Result = Class.new(Servactory::Result)
39
- RUBY
40
- end
41
-
42
30
  def _call!(context, **arguments)
43
31
  context.send(
44
32
  :_call!,
@@ -19,11 +19,11 @@ module Servactory
19
19
  new(context: context).send(:as_success)
20
20
  end
21
21
 
22
- def self.failure_for(exception:)
23
- new(exception: exception).send(:as_failure)
22
+ def self.failure_for(context:, exception:)
23
+ new(context: context, exception: exception).send(:as_failure)
24
24
  end
25
25
 
26
- def initialize(context: nil, exception: nil)
26
+ def initialize(context:, exception: nil)
27
27
  @context = context
28
28
  @exception = exception
29
29
  end
@@ -78,6 +78,10 @@ module Servactory
78
78
  false
79
79
  end
80
80
 
81
+ outputs.methods(false).each do |method_name|
82
+ define_singleton_method(method_name) { outputs.send(method_name) }
83
+ end
84
+
81
85
  self
82
86
  end
83
87
 
@@ -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 = 0
7
+ PATCH = 2
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.0
4
+ version: 2.4.2
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