metaractor 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Dockerfile +1 -1
- data/README.md +8 -0
- data/lib/metaractor/context_has_key.rb +9 -0
- data/lib/metaractor/parameters.rb +11 -0
- data/lib/metaractor/version.rb +1 -1
- data/lib/metaractor.rb +1 -0
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 26bc406252dfc7f8839f49ca5ee2a4a85cb1961db82c0a0a24928e964010ec17
|
4
|
+
data.tar.gz: b1412660d447cba69a18ffa3a290942de9339751abf2aebbd737b8326b7d7b57
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 02b54f2d308bbac395167a086aecbcca66bd2780a9a13871243ca150789b36d4f0717aec967b3fb5201e07e9ee9324b3a3ecfde203c2dd8bd3c15bc8d0b2ae22
|
7
|
+
data.tar.gz: ce8dda0f8c1a366dc311db0d32e7526d9fbf7bef45d23a3c77c49b67f591c06084f8a6a9ab1aa43063c002f42aaf1f1eecb93be10968b4803971cc6bc142a418
|
data/Dockerfile
CHANGED
data/README.md
CHANGED
@@ -74,6 +74,14 @@ As optional parameters have no enforcement, they are merely advisory.
|
|
74
74
|
optional :enable_logging
|
75
75
|
```
|
76
76
|
|
77
|
+
### Skipping Blank Parameter Removal
|
78
|
+
By default Metaractor removes blank values that are passed in. You may skip this behavior on a per-parameter basis:
|
79
|
+
```ruby
|
80
|
+
allow_blank :name
|
81
|
+
```
|
82
|
+
|
83
|
+
You may check to see if a parameter exists via `context.has_key?`.
|
84
|
+
|
77
85
|
### Custom Validation
|
78
86
|
Metaractor supports doing custom validation before any user supplied before_hooks run.
|
79
87
|
```ruby
|
@@ -8,6 +8,7 @@ module Metaractor
|
|
8
8
|
class << self
|
9
9
|
attr_writer :_required_parameters
|
10
10
|
attr_writer :_optional_parameters
|
11
|
+
attr_writer :_allow_blank
|
11
12
|
end
|
12
13
|
|
13
14
|
before :remove_blank_values
|
@@ -33,6 +34,14 @@ module Metaractor
|
|
33
34
|
self._optional_parameters += params
|
34
35
|
end
|
35
36
|
|
37
|
+
def _allow_blank
|
38
|
+
@_allow_blank ||= []
|
39
|
+
end
|
40
|
+
|
41
|
+
def allow_blank(*params)
|
42
|
+
self._allow_blank += params
|
43
|
+
end
|
44
|
+
|
36
45
|
def validate_parameters(*hooks, &block)
|
37
46
|
hooks << block if block
|
38
47
|
hooks.each {|hook| validate_hooks.push(hook) }
|
@@ -46,6 +55,8 @@ module Metaractor
|
|
46
55
|
def remove_blank_values
|
47
56
|
to_delete = []
|
48
57
|
context.each_pair do |k,v|
|
58
|
+
next if self.class._allow_blank.include?(k)
|
59
|
+
|
49
60
|
# The following regex is borrowed from Rails' String#blank?
|
50
61
|
to_delete << k if (v.is_a?(String) && /\A[[:space:]]*\z/ === v) || v.nil?
|
51
62
|
end
|
data/lib/metaractor/version.rb
CHANGED
data/lib/metaractor.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: metaractor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Schlesinger
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-01-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: interactor
|
@@ -85,6 +85,7 @@ files:
|
|
85
85
|
- lib/metaractor.rb
|
86
86
|
- lib/metaractor/chain_failures.rb
|
87
87
|
- lib/metaractor/context_errors.rb
|
88
|
+
- lib/metaractor/context_has_key.rb
|
88
89
|
- lib/metaractor/context_validity.rb
|
89
90
|
- lib/metaractor/errors.rb
|
90
91
|
- lib/metaractor/fail_from_context.rb
|
@@ -111,8 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
111
112
|
- !ruby/object:Gem::Version
|
112
113
|
version: '0'
|
113
114
|
requirements: []
|
114
|
-
|
115
|
-
rubygems_version: 2.7.7
|
115
|
+
rubygems_version: 3.0.3
|
116
116
|
signing_key:
|
117
117
|
specification_version: 4
|
118
118
|
summary: Adds parameter validation and error control to interactor
|