readymade 0.3.6 → 0.3.8
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 +4 -4
- data/CHANGELOG.md +8 -0
- data/Gemfile.lock +9 -9
- data/README.md +18 -0
- data/lib/readymade/action.rb +5 -3
- data/lib/readymade/response.rb +5 -0
- data/lib/readymade/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d23f98bdcf35999cfdad659cf75fb3e5f103da34508ec1b05cd18eb45465751e
|
4
|
+
data.tar.gz: 15d45fadf8ad68e6603959d6c6ae51b43407733c7458aa4ca20c94ad76bf6fd3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
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.
|
12
|
-
activesupport (= 7.0.
|
11
|
+
activejob (7.0.7.2)
|
12
|
+
activesupport (= 7.0.7.2)
|
13
13
|
globalid (>= 0.3.6)
|
14
|
-
activemodel (7.0.
|
15
|
-
activesupport (= 7.0.
|
16
|
-
activesupport (7.0.
|
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
|
25
|
-
activesupport (>=
|
24
|
+
globalid (1.2.1)
|
25
|
+
activesupport (>= 6.1)
|
26
26
|
i18n (1.14.1)
|
27
27
|
concurrent-ruby (~> 1.0)
|
28
|
-
minitest (5.
|
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
|
|
data/lib/readymade/action.rb
CHANGED
@@ -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
|
-
|
18
|
+
return res if res.try(:success?) || res.try(:consider_success?)
|
19
19
|
|
20
|
-
|
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
|
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)
|
data/lib/readymade/response.rb
CHANGED
@@ -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
|
|
data/lib/readymade/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2023-10-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: byebug
|