dry-transaction-extra 0.1.0 → 0.1.1

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: 655e43f9df76abfb9b93f04cf55ea437635662ffcfef58b78d1227f63d8560af
4
- data.tar.gz: 8343148513834477223867d864b9270f85109780b64ccbcd182373694cc2bd6b
3
+ metadata.gz: b418dfe409a43af2be1442c9816531076a476c16aa459b5203b49fb32d840836
4
+ data.tar.gz: be20845e12107f4e7b7b8b086dbead6b7920a1baf1bce41bd847922807c3e9d9
5
5
  SHA512:
6
- metadata.gz: ff3ce715ed177028996635b2bac116604447266d0952f7ef8ed33c1b69f3d727b3171903310233768d086af583b3103d258910cc34365b012ef57450f6faccf5
7
- data.tar.gz: 07012d6bbd9be48f99646389d020c90c92a9efdf02da014f66e3cccc04540fb122bf7ddbc26a2cbc5799a9c1d1671fb7399d2e0278f50b2a734004d7b816e73a
6
+ metadata.gz: d48878a62c1a65a8202021d7ccbb4a4e7c63cc4bc75e825a9f115c6060b75fefdd53abb2a2412acd869edaf9cb5f659f8a93804cd9d7d1a9fbf98f887cc464a9
7
+ data.tar.gz: c5fca1261a2e76d32a2b45ca33c0ab0f51cd911c61f8904306ff8437c6896a183d1108e6d6fbc8d26ec0fdb208d947e52707aa401efd6738e4eb1ad153d1d401
data/.rubocop.yml CHANGED
@@ -1,5 +1,6 @@
1
1
  AllCops:
2
2
  TargetRubyVersion: 3.2
3
+ NewCops: enable
3
4
 
4
5
  Layout/LineLength:
5
6
  Max: 120
data/README.md CHANGED
@@ -25,11 +25,18 @@ require "dry-transaction-extra"
25
25
 
26
26
  Dry::Transaction::Extra defines a few extra steps you can use:
27
27
 
28
- * [merge][#merge] -- Merges the output of the step with the input args. Best used with keyword arguments.
29
- * [tap][#tap] -- Similar to Ruby `Kernel#tap`, discards the return value of the step
28
+ * [merge](#merge) -- Merges the output of the step with the input args. Best
29
+ used with keyword arguments.
30
+ * [tap](#tap) -- Similar to Ruby `Kernel#tap`, discards the return value of the step
30
31
  and returns the original input. If the step fails, then returns the Failure
31
32
  instead.
32
- * [valid][#valid] -- Runs a Dry::Schema or Dry::Validation::Contract on the input, and transforms the validation Result to a Result monad.
33
+ * [valid](#valid) -- Runs a Dry::Schema or Dry::Validation::Contract on the
34
+ input, and transforms the validation Result to a Result monad.
35
+ * [use](#use) -- Invokes another transaction (or any other callable), and
36
+ merges the result.
37
+ * [maybe](#maybe) -- Optionally invokes another transaction by first
38
+ attempting to invoke the validator. If the validation fails, it continues to
39
+ the next step without failing.
33
40
 
34
41
  #### `merge`
35
42
 
@@ -173,8 +180,8 @@ valid ParamsValidator
173
180
 
174
181
  #### `maybe`
175
182
 
176
- Maybe combines the [`use`][#use] step with the [Validation
177
- extension][#validation]. Before attempting to run the provided transaction, it
183
+ Maybe combines the [`use`]( #use ) step with the [Validation
184
+ extension]( #validation ). Before attempting to run the provided transaction, it
178
185
  first runs its defined validator. If that validation passes, then it invokes
179
186
  the transaction. If the validation fails, however, then the transaction
180
187
  continues on, silently ignoring the failure. This is useful in several
@@ -227,7 +234,7 @@ class CreateUser
227
234
 
228
235
  #### Validation
229
236
 
230
- In addition to the [valid][#valid] step adapter, Dry::Transaction::Extra has
237
+ In addition to the [valid]( #valid ) step adapter, Dry::Transaction::Extra has
231
238
  support for an explicit "pre-flight" validation that runs as the first step.
232
239
 
233
240
  ```ruby
@@ -263,7 +270,7 @@ MyTransaction.new.call(args)
263
270
  MyTransaction.call(args)
264
271
  ```
265
272
 
266
- This is particularly useful when invoking transactions via the [`use`][#use] and [`maybe`][#maybe] steps:
273
+ This is particularly useful when invoking transactions via the [`use`]( #use ) and [`maybe`]( #maybe ) steps:
267
274
 
268
275
  ```
269
276
  use MyTransaction
@@ -41,9 +41,13 @@ module Dry
41
41
  txn = container[key] if key
42
42
  raise NoValidatorError, txn unless txn.respond_to? :validator
43
43
 
44
- result = txn.validator.new.call(*args).to_monad
45
- result.bind { txn.call(*args) }
46
- .or { Success(*args) }
44
+ result = txn.validator.new.call(*args)
45
+ if result.failure?
46
+ # Rails.logger.debug "Skipping #{txn} because of errors: #{result.errors.to_h}"
47
+ return Success(*args)
48
+ end
49
+
50
+ txn.call(*args)
47
51
  end
48
52
  rescue NoMethodError => e
49
53
  raise e unless e.name == :name
@@ -3,7 +3,7 @@
3
3
  module Dry
4
4
  module Transaction
5
5
  module Extra
6
- VERSION = "0.1.0"
6
+ VERSION = "0.1.1"
7
7
  end
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dry-transaction-extra
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Sadauskas
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-01-24 00:00:00.000000000 Z
11
+ date: 2023-07-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-monads
@@ -128,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
128
128
  - !ruby/object:Gem::Version
129
129
  version: '0'
130
130
  requirements: []
131
- rubygems_version: 3.4.1
131
+ rubygems_version: 3.4.10
132
132
  signing_key:
133
133
  specification_version: 4
134
134
  summary: Extra steps and functionality for Dry::Transaction