comandor 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +16 -0
- data/lib/comandor.rb +22 -1
- data/lib/comandor/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2e8d00a4c66e2d46005ab21115cf2da4e14e16e3
|
4
|
+
data.tar.gz: db387784f792404b6063c85319bf1ddf528dc6a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8f4ed9df50116f37214b853b9722a9d68521182bba5c7df130d4629505d13ef4134b18946eff26a99b55602fb5aba91ab1939c78af7bfbcbf0e7483077ee2511
|
7
|
+
data.tar.gz: 97a1ce2e6f1ee46f465d350b1768ef1e4d03b9e3a2e9aeda0490d3a9199ed8c07fcf8845dad9c4c01cbdc7eec0e02fdb9b122cbb5fbc446f24ddd40f82900f72
|
data/README.md
CHANGED
@@ -172,6 +172,22 @@ example of using:
|
|
172
172
|
end
|
173
173
|
```
|
174
174
|
|
175
|
+
`transaction!` wrapper around `perform` method look like
|
176
|
+
```ruby
|
177
|
+
class User::Message
|
178
|
+
extend Comandor
|
179
|
+
transaction! 'ActiveRecord::Base.transaction'
|
180
|
+
|
181
|
+
def perform(user)
|
182
|
+
@user = user
|
183
|
+
create_message! && send_message! && write_log! &&
|
184
|
+
end
|
185
|
+
#...
|
186
|
+
end
|
187
|
+
|
188
|
+
User::Message.perform(User.first)
|
189
|
+
```
|
190
|
+
|
175
191
|
## Development
|
176
192
|
|
177
193
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/lib/comandor.rb
CHANGED
@@ -17,12 +17,33 @@ module Comandor
|
|
17
17
|
def perform(*args, &block)
|
18
18
|
new.perform(*args, &block)
|
19
19
|
end
|
20
|
+
|
21
|
+
# Add transaction layer
|
22
|
+
# @param [name] [String] ActiveRecord::Base.transaction
|
23
|
+
def transaction!(name)
|
24
|
+
class_eval { @transaction_klass, @transaction_method = name.split('.') }
|
25
|
+
end
|
26
|
+
|
27
|
+
# Class variables accessor
|
28
|
+
def transaction_klass
|
29
|
+
@transaction_klass
|
30
|
+
end
|
31
|
+
|
32
|
+
def transaction_method
|
33
|
+
@transaction_method
|
34
|
+
end
|
20
35
|
end
|
21
36
|
|
22
37
|
# @return [self]
|
23
38
|
def perform(*args, &block)
|
24
39
|
raise NoMethodError unless defined?(:perform)
|
25
|
-
|
40
|
+
if self.class.transaction_klass && self.class.transaction_method
|
41
|
+
@result = Object.const_get(self.class.transaction_klass).send self.class.transaction_method.to_sym do
|
42
|
+
super
|
43
|
+
end
|
44
|
+
else
|
45
|
+
@result = super
|
46
|
+
end
|
26
47
|
@done = true
|
27
48
|
self
|
28
49
|
end
|
data/lib/comandor/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: comandor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Renat "MpaK" Ibragimov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-01-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|