flakes 0.2.2 → 0.3.0
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/lib/flakes.rb +21 -2
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 03b2fbd1ce7072c95eabe1b4040db78c9c03ffa0
|
|
4
|
+
data.tar.gz: f1b0e0ea74607a00703698e49989b9c45fe88b2d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d6e8183b52108b5b076859ae402bba98e3e172f6944c48219547eb30d1ad27eae3f713b290735bebf15a65889496ab9d26745136360be4f55c7a0e7fcdd49aab
|
|
7
|
+
data.tar.gz: 6030b6eaaa7e933e579adbc3e02806931c5638f37f54ceb78405d2d0212d9fd472641f99a618d1658554bbc3257a79de928c4aac0749358e20a968b5ae08b55e
|
data/lib/flakes.rb
CHANGED
|
@@ -2,6 +2,9 @@ require "active_job"
|
|
|
2
2
|
require "active_model"
|
|
3
3
|
|
|
4
4
|
class Flake < ActiveJob::Base
|
|
5
|
+
class Error < StandardError
|
|
6
|
+
end
|
|
7
|
+
|
|
5
8
|
# alias ActiveJob::Core#initialize before it is overwritten by ActiveModel::Model
|
|
6
9
|
alias_method :active_job_initialize, :initialize
|
|
7
10
|
|
|
@@ -37,14 +40,30 @@ class Flake < ActiveJob::Base
|
|
|
37
40
|
|
|
38
41
|
private
|
|
39
42
|
|
|
43
|
+
def with_valid_params
|
|
44
|
+
if block_given? && valid?
|
|
45
|
+
ApplicationRecord.transaction do
|
|
46
|
+
yield
|
|
47
|
+
end
|
|
48
|
+
else
|
|
49
|
+
failure(errors)
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
40
53
|
def success(*args)
|
|
41
|
-
|
|
42
|
-
|
|
54
|
+
if args.size == 1 && args.first.respond_to?(:errors) && args.first.errors.present?
|
|
55
|
+
failure(args.first.errors)
|
|
56
|
+
else
|
|
57
|
+
@success ||= default_success
|
|
58
|
+
@success.call(*args)
|
|
59
|
+
return args.first
|
|
60
|
+
end
|
|
43
61
|
end
|
|
44
62
|
|
|
45
63
|
def failure(*args)
|
|
46
64
|
@failure ||= default_failure
|
|
47
65
|
@failure.call(*args)
|
|
66
|
+
false
|
|
48
67
|
end
|
|
49
68
|
|
|
50
69
|
def default_success
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: flakes
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Manuel Schiner
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2016-
|
|
11
|
+
date: 2016-09-10 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activemodel
|
|
@@ -122,7 +122,7 @@ dependencies:
|
|
|
122
122
|
- - "~>"
|
|
123
123
|
- !ruby/object:Gem::Version
|
|
124
124
|
version: '4.7'
|
|
125
|
-
description:
|
|
125
|
+
description: framework for rails business logic
|
|
126
126
|
email: maschiner@maschiner.com
|
|
127
127
|
executables: []
|
|
128
128
|
extensions: []
|