attestor 0.4.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/attestor.rb +0 -1
- data/lib/attestor/validations.rb +0 -16
- data/lib/attestor/validations/validators.rb +2 -10
- data/lib/attestor/version.rb +1 -1
- metadata +1 -2
- data/lib/attestor/validations/follower.rb +0 -35
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3030abf371f99cd2d342e227e8d054fb718d0597
|
4
|
+
data.tar.gz: 9742b46202b9d6e2cff850f6e52243f8668bdde7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 83ae6c32bb6be7ba47304a37ddc811ac3a22f761883dfc432f79533a2b7904860c2c81bd32e36b11d7e46e6ee445943074391dd90dab306e24548d2da58fd8d6
|
7
|
+
data.tar.gz: a1d2d13d9c1c7b16e942755b482dae67d8aefb1ed12ee4ca31755d4b31d787ed5db915190af62ba4ed7893b98a6ceb41d6feacd4c7b2c7e8e3ff925291528d5b
|
data/lib/attestor.rb
CHANGED
@@ -9,7 +9,6 @@ require_relative "attestor/invalid_error"
|
|
9
9
|
require_relative "attestor/validations"
|
10
10
|
require_relative "attestor/validations/validator"
|
11
11
|
require_relative "attestor/validations/delegator"
|
12
|
-
require_relative "attestor/validations/follower"
|
13
12
|
require_relative "attestor/validations/validators"
|
14
13
|
require_relative "attestor/validations/message"
|
15
14
|
|
data/lib/attestor/validations.rb
CHANGED
@@ -100,22 +100,6 @@ module Attestor
|
|
100
100
|
@validators = validators.add_delegator(*args, &block)
|
101
101
|
end
|
102
102
|
|
103
|
-
# @!method follow_policy(name, except: nil, only: nil)
|
104
|
-
# Registers a followed policy
|
105
|
-
#
|
106
|
-
# Mutates the class by changing its {#validators} attribute!
|
107
|
-
#
|
108
|
-
# @param [#to_sym] name
|
109
|
-
# @option [#to_sym, Array<#to_sym>] :except
|
110
|
-
# the black list of contexts for validation
|
111
|
-
# @option [#to_sym, Array<#to_sym>] :only
|
112
|
-
# the white list of contexts for validation
|
113
|
-
#
|
114
|
-
# @return [Attestor::Collection] the updated collection
|
115
|
-
def follow_policy(*args)
|
116
|
-
@validators = validators.add_follower(*args)
|
117
|
-
end
|
118
|
-
|
119
103
|
end # module ClassMethods
|
120
104
|
|
121
105
|
# @private
|
@@ -42,7 +42,7 @@ module Attestor
|
|
42
42
|
# @return [Attestor::Validators]
|
43
43
|
def set(context)
|
44
44
|
validators = select { |item| item.used_in_context? context }
|
45
|
-
|
45
|
+
|
46
46
|
self.class.new(validators)
|
47
47
|
end
|
48
48
|
|
@@ -64,20 +64,12 @@ module Attestor
|
|
64
64
|
add_item Delegator, *args, &block
|
65
65
|
end
|
66
66
|
|
67
|
-
# @deprecated
|
68
|
-
def add_follower(*args)
|
69
|
-
warn "[DEPRECATED] .add_follower is deprecated since v1.0.0" \
|
70
|
-
" Use .validates method instead."
|
71
|
-
add_item Follower, *args
|
72
|
-
end
|
73
|
-
|
74
67
|
private
|
75
68
|
|
76
69
|
attr_reader :items
|
77
70
|
|
78
71
|
def add_item(type, *args, &block)
|
79
|
-
|
80
|
-
include?(item) ? self : self.class.new(items, item)
|
72
|
+
self.class.new items, type.new(*args, &block)
|
81
73
|
end
|
82
74
|
|
83
75
|
end # class Validators
|
data/lib/attestor/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: attestor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kozin
|
@@ -82,7 +82,6 @@ files:
|
|
82
82
|
- lib/attestor/policy/xor.rb
|
83
83
|
- lib/attestor/validations.rb
|
84
84
|
- lib/attestor/validations/delegator.rb
|
85
|
-
- lib/attestor/validations/follower.rb
|
86
85
|
- lib/attestor/validations/message.rb
|
87
86
|
- lib/attestor/validations/validator.rb
|
88
87
|
- lib/attestor/validations/validators.rb
|
@@ -1,35 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
module Attestor
|
4
|
-
|
5
|
-
module Validations
|
6
|
-
|
7
|
-
# Describe a policy follower for class instances
|
8
|
-
#
|
9
|
-
# The follower not only calls an instance method (as validator does),
|
10
|
-
# but checks whether the result is valid and raises an exception otherwise.
|
11
|
-
#
|
12
|
-
# @example
|
13
|
-
# follower = Validator.new(:foo, only: :baz) { FooPolicy.new(foo) }
|
14
|
-
#
|
15
|
-
# @api private
|
16
|
-
class Follower < Validator
|
17
|
-
|
18
|
-
# Validates a policy
|
19
|
-
#
|
20
|
-
# @param [Object] object
|
21
|
-
#
|
22
|
-
# @raise [Attestor::InvalidError] if a policy isn't valid
|
23
|
-
#
|
24
|
-
# @return [undefined]
|
25
|
-
def validate(object)
|
26
|
-
policy = super(object)
|
27
|
-
return if policy.valid?
|
28
|
-
object.__send__ :invalid, name
|
29
|
-
end
|
30
|
-
|
31
|
-
end # class Follower
|
32
|
-
|
33
|
-
end # module Validations
|
34
|
-
|
35
|
-
end # module Attestor
|