methodist 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/methodist/interactor.rb +14 -3
- data/lib/methodist/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d4b0a1df657cf96583bdecf926cfa5beb74711aa2e942a47756e3eae03712ce8
|
4
|
+
data.tar.gz: ac96de08d5807f11da740f6356d246f2581c5befbe55e811b199cf6295935cd4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 934db6fde4c720b1cf7777a1107967a700c710c1430aeb3952b2dbb9021458848b4f243d2f0d5740098e6707002e785a6ae29aba770e41d45c9a1bcbb3c00da6
|
7
|
+
data.tar.gz: 45aea636ce515ddd5a5e8366e3d6cf337d16e18f93e675399c57cee8fcfe6003e555c1937268ee4d4eee87870590e91328d75451308470974c927125ecaba9c2
|
data/lib/methodist/interactor.rb
CHANGED
@@ -10,6 +10,7 @@ require "dry/validation"
|
|
10
10
|
#
|
11
11
|
class Methodist::Interactor < Methodist::Pattern
|
12
12
|
include Dry::Transaction
|
13
|
+
NEW_DRY_VALIDATION_V = '1.0.0'.freeze
|
13
14
|
|
14
15
|
attr_accessor :validation_result
|
15
16
|
|
@@ -39,11 +40,22 @@ class Methodist::Interactor < Methodist::Pattern
|
|
39
40
|
##
|
40
41
|
def schema(&block)
|
41
42
|
if block_given?
|
42
|
-
@input_schema =
|
43
|
+
@input_schema = dry_schema(&block)
|
43
44
|
else
|
44
45
|
raise SchemaDefinitionError, 'You must pass block to `schema`'
|
45
46
|
end
|
46
47
|
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
def dry_schema(&block)
|
52
|
+
return Dry::Schema.Params(&block) if new_dry_validation?
|
53
|
+
Dry::Validation.Schema(&block)
|
54
|
+
end
|
55
|
+
|
56
|
+
def new_dry_validation?
|
57
|
+
Gem.loaded_specs['dry-validation'].version.to_s >= NEW_DRY_VALIDATION_V
|
58
|
+
end
|
47
59
|
end
|
48
60
|
|
49
61
|
##
|
@@ -100,7 +112,7 @@ class Methodist::Interactor < Methodist::Pattern
|
|
100
112
|
# Method for validation input of interactor parameters.
|
101
113
|
##
|
102
114
|
def failure_validation_value
|
103
|
-
field = validation_result.errors.keys.first
|
115
|
+
field = validation_result.errors.to_hash.keys.first
|
104
116
|
{
|
105
117
|
error: 'ValidationError',
|
106
118
|
field: field,
|
@@ -108,7 +120,6 @@ class Methodist::Interactor < Methodist::Pattern
|
|
108
120
|
}
|
109
121
|
end
|
110
122
|
|
111
|
-
|
112
123
|
class SchemaDefinitionError < StandardError; end
|
113
124
|
class InputClassError < StandardError; end
|
114
125
|
end
|
data/lib/methodist/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: methodist
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sergey Nesterov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-12-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -28,14 +28,14 @@ dependencies:
|
|
28
28
|
name: dry-validation
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0.13'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0.13'
|
41
41
|
- !ruby/object:Gem::Dependency
|
@@ -170,7 +170,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
170
170
|
- !ruby/object:Gem::Version
|
171
171
|
version: '0'
|
172
172
|
requirements: []
|
173
|
-
rubygems_version: 3.0.
|
173
|
+
rubygems_version: 3.0.6
|
174
174
|
signing_key:
|
175
175
|
specification_version: 4
|
176
176
|
summary: Gem for Ruby on Rails created to stop chaos in your buisness logic.
|