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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7889c90de0f2f5e7a65ac09a622200903219fecf
4
- data.tar.gz: da24f1d17b8705a96f505e28063b44d38051c222
3
+ metadata.gz: 3030abf371f99cd2d342e227e8d054fb718d0597
4
+ data.tar.gz: 9742b46202b9d6e2cff850f6e52243f8668bdde7
5
5
  SHA512:
6
- metadata.gz: dd38ec23f72df933af48dfbdc3cbf26ec10845f4c6b6ec56796537c20c42b09d93113929efe89292835adcc1cf378894209dc87773b8f1870247e1a79ceda67c
7
- data.tar.gz: ef469dd31b6df6f9f3176e5ebc74bff358e271b3c42974e6a70a07595369d66818585aea3aa660a3e54c2c646a959f6c26df8b18fff8c05502bdd2e3b08d260a
6
+ metadata.gz: 83ae6c32bb6be7ba47304a37ddc811ac3a22f761883dfc432f79533a2b7904860c2c81bd32e36b11d7e46e6ee445943074391dd90dab306e24548d2da58fd8d6
7
+ data.tar.gz: a1d2d13d9c1c7b16e942755b482dae67d8aefb1ed12ee4ca31755d4b31d787ed5db915190af62ba4ed7893b98a6ceb41d6feacd4c7b2c7e8e3ff925291528d5b
@@ -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
 
@@ -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
- item = type.new(*args, &block)
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
@@ -4,6 +4,6 @@ module Attestor
4
4
 
5
5
  # The semantic version of the module.
6
6
  # @see http://semver.org/ Semantic versioning 2.0
7
- VERSION = "0.4.0".freeze
7
+ VERSION = "1.0.0".freeze
8
8
 
9
9
  end # module Attestor
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.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