activeinteractor 2.0.0.alpha.2.0.0 → 2.0.0.alpha.2.1.0

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: 2a13c3091acf37b48e249f912e5551da92b039e17920e53c1082ebcc4b34f4c2
4
- data.tar.gz: 8e1e80f06675574384eeae45835f6372bf04d7378cdf64f7f21323d36857a7e4
3
+ metadata.gz: 8353806528fdb9ad9625f469d16d400929d9ef3cae024490c85982354f4d9bad
4
+ data.tar.gz: af9cfad32cffe177d1b30fa7fb482f3305a6757152090d82482aef39f448a628
5
5
  SHA512:
6
- metadata.gz: 6b006f6e815419f58a6b6f063d37db8beae1e1ad239d98635545bb267d2c09df9307ec80528c1785035013aeaf07f27a73fcd1668dac44115e466109da675910
7
- data.tar.gz: 3f0d5b6fd50726ec6539b691257d00d85254e1ca74c06727d84da7763e8545d033650c6ec7482f307e622e77bff2bc8fcae25e54c2f6a15208377258dac1d814
6
+ metadata.gz: 45a07cd05ee5ad9e27fb23f2ebe1a99c5bc01cdeeda5987e35a501b22230ecb56ea49ccc36c233348a838a6c25cd2fa8b6945326bef13839d1f4541a0d3ac043
7
+ data.tar.gz: c11cbf40fa73910ce12a43a60db15f13983ec6174006627eae29eecd068002be2fcbd50b7062d4cd0d955736594a246611f66c570db59b152e889053c9b5128d
@@ -36,8 +36,10 @@ module ActiveInteractor
36
36
  end
37
37
 
38
38
  def perform!
39
- interact
40
- Result.success(data: parse_output!)
39
+ with_notification(:perform) do |payload|
40
+ interact
41
+ payload[:result] = Result.success(data: parse_output!)
42
+ end
41
43
  end
42
44
 
43
45
  def perform
@@ -56,8 +58,14 @@ module ActiveInteractor
56
58
  attr_accessor :context
57
59
 
58
60
  def fail!(errors = {})
59
- rollback
60
- raise Error, Result.failure(data: context, errors: errors)
61
+ result = nil
62
+ with_notification(:rollback) do |payload|
63
+ rollback
64
+ result = Result.failure(data: parse_output!, errors: errors)
65
+ payload[:result] = result
66
+ end
67
+
68
+ raise Error, result
61
69
  end
62
70
 
63
71
  def parse_input!
@@ -91,5 +99,11 @@ module ActiveInteractor
91
99
  errors[attribute_name] << :blank
92
100
  errors
93
101
  end
102
+
103
+ def with_notification(action)
104
+ ActiveSupport::Notifications.instrument("#{self.class.name}::#{action.to_s.classify}") do |payload|
105
+ yield payload if block_given?
106
+ end
107
+ end
94
108
  end
95
109
  end
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'active_model'
4
4
  require 'active_support'
5
+ require 'active_support/core_ext'
5
6
 
6
7
  require_relative 'active_interactor/errors'
7
8
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activeinteractor
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.alpha.2.0.0
4
+ version: 2.0.0.alpha.2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Allen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-10-10 00:00:00.000000000 Z
11
+ date: 2023-10-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -72,9 +72,9 @@ licenses:
72
72
  - MIT
73
73
  metadata:
74
74
  bug_tracker_uri: https://github.com/activeinteractor/activeinteractor/issues
75
- changelog_uri: https://github.com/activeinteractor/activeinteractor/blob/v2.0.0-alpha.2.0.0/CHANGELOG.md
75
+ changelog_uri: https://github.com/activeinteractor/activeinteractor/blob/v2.0.0-alpha.2.1.0/CHANGELOG.md
76
76
  homepage_uri: https://github.com/activeinteractor/activeinteractor
77
- source_code_uri: https://github.com/activeinteractor/activeinteractor/tree/v2.0.0-alpha.2.0.0
77
+ source_code_uri: https://github.com/activeinteractor/activeinteractor/tree/v2.0.0-alpha.2.1.0
78
78
  wiki_uri: https://github.com/activeinteractor/activeinteractor/wiki
79
79
  rubygems_mfa_required: 'true'
80
80
  post_install_message: