business_flow 0.4.3 → 0.4.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/business_flow/dsl.rb +5 -1
- data/lib/business_flow/not_nil_validator.rb +7 -3
- data/lib/business_flow/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: c64b686d7c5bc163fe6b12e9dbe8f697a93818be
|
4
|
+
data.tar.gz: 3e689698a828b138adcacde97be3fd97724814ee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 28e9939de69fa659e98f87e26fc7454fac38b597f6c985d6f47cb56249825752c0992596b282ae22b2f54111afc04cfdf52417ebe8336443918dac0762be52fc
|
7
|
+
data.tar.gz: 4e72d98e7422b5c3738a82d9a7d127d41aaf11e9a8903b2d78966442928ea1429838a45ebfc8d1b26c30a866b567e67b5e07450f897b029794c080f414329b40
|
data/Gemfile.lock
CHANGED
data/lib/business_flow/dsl.rb
CHANGED
@@ -8,6 +8,8 @@ module BusinessFlow
|
|
8
8
|
# was initialized with. The provided .call will instantiate the including
|
9
9
|
# class with a parameter_object as the only argument.
|
10
10
|
module ClassMethods
|
11
|
+
attr_reader :requirements
|
12
|
+
|
11
13
|
# Requires that a field be retrievable from the initialization parameters
|
12
14
|
#
|
13
15
|
# This will only require that the field is not nil. The field may still
|
@@ -15,7 +17,8 @@ module BusinessFlow
|
|
15
17
|
#
|
16
18
|
# @param fields The fields required from the initialization parameters
|
17
19
|
def needs(*fields)
|
18
|
-
|
20
|
+
@requirements ||= []
|
21
|
+
@requirements.push(*fields)
|
19
22
|
wants(*fields)
|
20
23
|
end
|
21
24
|
|
@@ -72,6 +75,7 @@ module BusinessFlow
|
|
72
75
|
# See above -- that this is an alias is considered public API.
|
73
76
|
alias invariant validates
|
74
77
|
end
|
78
|
+
validates_with NotNilValidator
|
75
79
|
end
|
76
80
|
end
|
77
81
|
|
@@ -1,11 +1,15 @@
|
|
1
1
|
module BusinessFlow
|
2
2
|
# Validate that a given value is not nil, but allow blank/empty values.
|
3
|
-
class NotNilValidator < ActiveModel::
|
3
|
+
class NotNilValidator < ActiveModel::Validator
|
4
4
|
# :reek:NilCheck :reek:UtilityFunction
|
5
5
|
# Dear reek -- I didn't decided the ActiveModel Validator API, I just
|
6
6
|
# have to live with it.
|
7
|
-
def
|
8
|
-
record.
|
7
|
+
def validate(record)
|
8
|
+
requirements = record.class.requirements || []
|
9
|
+
requirements.each do |attribute|
|
10
|
+
value = record.read_attribute_for_validation(attribute)
|
11
|
+
record.errors[attribute] << 'must not be nil' if value.nil?
|
12
|
+
end
|
9
13
|
end
|
10
14
|
end
|
11
15
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: business_flow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Scarborough
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-03-
|
11
|
+
date: 2018-03-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|