readymade 0.3.6 → 0.3.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: 90f0eb0091bea1e29078e83958d77aedfa989c39af4d21213bec81347f4d73df
4
- data.tar.gz: b96a07f92350bee6be041456b979dc781ad1324ad8ef38e95547f9af34a250a8
3
+ metadata.gz: d23f98bdcf35999cfdad659cf75fb3e5f103da34508ec1b05cd18eb45465751e
4
+ data.tar.gz: 15d45fadf8ad68e6603959d6c6ae51b43407733c7458aa4ca20c94ad76bf6fd3
5
5
  SHA512:
6
- metadata.gz: 82b0f5dbc204ea624d84c48edc4b6619216c300d447f1cae69a1828b88d4533b2048960757f2e354f5adf15400b993b2efff92e0e44f4e2c6e8e38a50a7a8221
7
- data.tar.gz: 21b076ad062a65ed5afde67521ee433f99228cedf0d0b229079270e6f3793b7e4097a48ba02c9c81e7f5f84eedef8b0fc565f1ade7dbdfd518c91cbfb346227c
6
+ metadata.gz: f5ec8fa06c4198d1281decc771ea8a9ed721a4ca75f17f983b82fc4dd000ad67a3c3b7116e57ae0324edc266055da18a394f36431c7ca2ed68a4a3fb29f31538
7
+ data.tar.gz: 5b14c12db646986bb0746e783ca04f075739f84b23f3ef2db12595c993108586350a11aff2ce3bc3257b3861c8625ac487d91a84a8a6baf0608f2175b55595c8
data/CHANGELOG.md CHANGED
@@ -1,6 +1,14 @@
1
1
  Changelog
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
+ ## [0.3.8] - 2023-10-06
5
+
6
+ * Add `conisder_success` argument to Response
7
+
8
+ ## [0.3.7] - 2023-08-08
9
+
10
+ * Fix invalid behaviour of `call!` method
11
+
4
12
  ## [0.3.6] - 2023-07-21
5
13
 
6
14
  * Add `queue_as: :name` argument to `Readymade::BackgroundJob` to select queue name when using `.call_async(args.merge(queue_as: :my_queue))`
data/Gemfile.lock CHANGED
@@ -1,19 +1,19 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- readymade (0.3.6)
4
+ readymade (0.3.8)
5
5
  activejob
6
6
  activemodel
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- activejob (7.0.5)
12
- activesupport (= 7.0.5)
11
+ activejob (7.0.7.2)
12
+ activesupport (= 7.0.7.2)
13
13
  globalid (>= 0.3.6)
14
- activemodel (7.0.5)
15
- activesupport (= 7.0.5)
16
- activesupport (7.0.5)
14
+ activemodel (7.0.7.2)
15
+ activesupport (= 7.0.7.2)
16
+ activesupport (7.0.7.2)
17
17
  concurrent-ruby (~> 1.0, >= 1.0.2)
18
18
  i18n (>= 1.6, < 2)
19
19
  minitest (>= 5.1)
@@ -21,11 +21,11 @@ GEM
21
21
  byebug (11.1.3)
22
22
  concurrent-ruby (1.2.2)
23
23
  diff-lcs (1.4.4)
24
- globalid (1.1.0)
25
- activesupport (>= 5.0)
24
+ globalid (1.2.1)
25
+ activesupport (>= 6.1)
26
26
  i18n (1.14.1)
27
27
  concurrent-ruby (~> 1.0)
28
- minitest (5.18.1)
28
+ minitest (5.19.0)
29
29
  rake (13.0.6)
30
30
  rspec (3.10.0)
31
31
  rspec-core (~> 3.10.0)
data/README.md CHANGED
@@ -169,6 +169,24 @@ end
169
169
 
170
170
  Orders::Actions::SendNotifications.call!(order: order) # raise error if response is fail
171
171
  ```
172
+
173
+ ### `.call` + `conisder_success: true`
174
+ ```ruby
175
+ class Orders::Actions::SendNotifications < Readymade::Action
176
+ def call!
177
+ send_email
178
+ return response(:skip, consider_success: true) if skip_email?
179
+ send_push
180
+ send_slack
181
+
182
+ response(:success, record: record, any_other_data: data)
183
+ end
184
+ ...
185
+ end
186
+
187
+ Orders::Actions::SendNotifications.call!(order: order) # does not raise error if skip_email? returns true
188
+ ```
189
+
172
190
  ### `.call_async!` - runs in background and raise error unless response is success
173
191
  (action must return Readymade::Response.new(:success))
174
192
 
@@ -15,9 +15,9 @@ module Readymade
15
15
 
16
16
  def self.call!(*args, &block)
17
17
  new(*args, &block).call!.then do |res|
18
- raise UnSuccessError unless res.try(:success?)
18
+ return res if res.try(:success?) || res.try(:consider_success?)
19
19
 
20
- res
20
+ raise UnSuccessError
21
21
  end
22
22
  end
23
23
 
@@ -42,7 +42,9 @@ module Readymade
42
42
 
43
43
  def call; end
44
44
 
45
- def call!; end
45
+ def call!
46
+ call
47
+ end
46
48
 
47
49
  def call_async
48
50
  ::Readymade::BackgroundJob.perform_later(class_name: self.class.name, **args)
@@ -20,6 +20,7 @@ module Readymade
20
20
  raise NonKeywordArgumentsError if args.present? && !args[0].is_a?(Hash)
21
21
 
22
22
  @args = @data = args[0]
23
+ @consider_success = @args.delete(:consider_success) if @args.present?
23
24
 
24
25
  define_singleton_method("#{status}?") do
25
26
  true
@@ -30,6 +31,10 @@ module Readymade
30
31
  args[:errors].presence || {}
31
32
  end
32
33
 
34
+ def consider_success?
35
+ @consider_success
36
+ end
37
+
33
38
  def method_missing(method_name, *args, &block)
34
39
  return false if method_name.to_s.end_with?('?')
35
40
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Readymade
4
- VERSION = '0.3.6'
4
+ VERSION = '0.3.8'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: readymade
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.6
4
+ version: 0.3.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - OrestF
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-07-21 00:00:00.000000000 Z
11
+ date: 2023-10-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: byebug