core-boundary 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/lib/core/boundary/behavior/normalization.rb +4 -4
- data/lib/core/boundary/behavior/validation.rb +4 -4
- data/lib/core/boundary/behavior/verifiable.rb +4 -4
- data/lib/core/boundary/normalizer.rb +7 -8
- data/lib/core/boundary/reference.rb +2 -2
- data/lib/core/boundary/result.rb +2 -2
- data/lib/core/boundary/validator.rb +7 -8
- data/lib/core/boundary/verifier.rb +37 -10
- data/lib/core/boundary/version.rb +1 -1
- data/lib/core/boundary.rb +103 -3
- metadata +12 -14
- data/lib/core/boundary/bootstrap.rb +0 -4
- data/lib/is/boundary.rb +0 -109
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 888c832c6456608723ba3bbc4ca60d75bc0daf7025da4a6c4c0c1dd0eb7c8b55
|
4
|
+
data.tar.gz: a2d8727f09455b413529c87bd3f283a72c385b1ebdb14a264b0be9835d698518
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b81d6d3e0348016fb1e6742e01a2fb5353ae391a8f274f1dec7c322243982c80af1e1118c7bb3cf753deb6f42839e671eb4c95bda4d499d56652f2811fb8da48
|
7
|
+
data.tar.gz: f58d23822333f25076e0bcbcb4eac07a308133e30fedf30049925c67efa3f22ddfc16d08f2170d76cefd71fff49b96b25af1422eb553040920cab48559031f02
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
## [v0.1.0](https://github.com/bryanp/corerb/releases/tag/2023-12-24)
|
2
|
+
|
3
|
+
*released on 2023-12-24*
|
4
|
+
|
5
|
+
* `add` [#147](https://github.com/bryanp/corerb/pull/147) Add support for verification modules ([bryanp](https://github.com/bryanp))
|
6
|
+
* `dep` [#143](https://github.com/bryanp/corerb/pull/143) Deprecate `Is::*` and `Refine::*` namespaces ([bryanp](https://github.com/bryanp))
|
7
|
+
|
1
8
|
## [v0.0.1](https://github.com/bryanp/corerb/releases/tag/2023-12-20)
|
2
9
|
|
3
10
|
*released on 2023-12-20*
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "
|
4
|
-
require "
|
3
|
+
require "core/extension"
|
4
|
+
require "core/state"
|
5
5
|
|
6
6
|
require_relative "../normalizer"
|
7
7
|
|
@@ -11,7 +11,7 @@ module Core
|
|
11
11
|
# [public]
|
12
12
|
#
|
13
13
|
module Normalization
|
14
|
-
extend
|
14
|
+
extend Core::Extension
|
15
15
|
|
16
16
|
# [public]
|
17
17
|
#
|
@@ -19,7 +19,7 @@ module Core
|
|
19
19
|
normalizer.action(&block)
|
20
20
|
end
|
21
21
|
|
22
|
-
extends dependencies: [
|
22
|
+
extends dependencies: [Core::State]
|
23
23
|
|
24
24
|
applies do
|
25
25
|
state :normalizer, default: Normalizer.new
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "
|
4
|
-
require "
|
3
|
+
require "core/extension"
|
4
|
+
require "core/state"
|
5
5
|
|
6
6
|
require_relative "../validator"
|
7
7
|
|
@@ -11,7 +11,7 @@ module Core
|
|
11
11
|
# [public]
|
12
12
|
#
|
13
13
|
module Validation
|
14
|
-
extend
|
14
|
+
extend Core::Extension
|
15
15
|
|
16
16
|
# [public]
|
17
17
|
#
|
@@ -19,7 +19,7 @@ module Core
|
|
19
19
|
validator.action(name, &block)
|
20
20
|
end
|
21
21
|
|
22
|
-
extends dependencies: [
|
22
|
+
extends dependencies: [Core::State]
|
23
23
|
|
24
24
|
applies do
|
25
25
|
state :validator, default: Validator.new
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "
|
4
|
-
require "
|
3
|
+
require "core/extension"
|
4
|
+
require "core/state"
|
5
5
|
|
6
6
|
require_relative "../verifier"
|
7
7
|
|
@@ -11,7 +11,7 @@ module Core
|
|
11
11
|
# [public]
|
12
12
|
#
|
13
13
|
module Verifiable
|
14
|
-
extend
|
14
|
+
extend Core::Extension
|
15
15
|
|
16
16
|
# [public]
|
17
17
|
#
|
@@ -25,7 +25,7 @@ module Core
|
|
25
25
|
verifier.optional(...)
|
26
26
|
end
|
27
27
|
|
28
|
-
extends dependencies: [
|
28
|
+
extends dependencies: [Core::State]
|
29
29
|
|
30
30
|
applies do
|
31
31
|
state :verifier, default: Verifier.new
|
@@ -1,26 +1,25 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "
|
4
|
-
require "
|
5
|
-
|
6
|
-
require "refine/object/copy"
|
3
|
+
require "core/copy"
|
4
|
+
require "core/inspect"
|
7
5
|
|
8
6
|
module Core
|
9
7
|
module Boundary
|
10
8
|
# [public]
|
11
9
|
#
|
12
10
|
class Normalizer
|
13
|
-
include
|
14
|
-
include Is::Inspectable
|
11
|
+
include Core::Inspect
|
15
12
|
|
16
|
-
using
|
13
|
+
using Core::Copy
|
17
14
|
|
18
15
|
def initialize
|
19
16
|
@actions = []
|
20
17
|
end
|
21
18
|
|
22
|
-
|
19
|
+
def initialize_copy(...)
|
23
20
|
@actions = @actions.copy
|
21
|
+
|
22
|
+
super
|
24
23
|
end
|
25
24
|
|
26
25
|
# [public]
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "core/type"
|
4
|
-
require "
|
4
|
+
require "core/inspect"
|
5
5
|
|
6
6
|
require_relative "behavior/normalization"
|
7
7
|
require_relative "behavior/validation"
|
@@ -14,7 +14,7 @@ module Core
|
|
14
14
|
include Behavior::Normalization
|
15
15
|
include Behavior::Validation
|
16
16
|
|
17
|
-
include
|
17
|
+
include Core::Inspect
|
18
18
|
inspects without: [:@stringified]
|
19
19
|
|
20
20
|
UNDEFINED = Object.new
|
data/lib/core/boundary/result.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "
|
3
|
+
require "core/inspect"
|
4
4
|
|
5
5
|
require_relative "errors"
|
6
6
|
|
@@ -9,7 +9,7 @@ module Core
|
|
9
9
|
# [public]
|
10
10
|
#
|
11
11
|
class Result
|
12
|
-
include
|
12
|
+
include Core::Inspect
|
13
13
|
inspects :@values, :@errors
|
14
14
|
|
15
15
|
def initialize
|
@@ -1,26 +1,25 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "
|
4
|
-
require "
|
5
|
-
|
6
|
-
require "refine/object/copy"
|
3
|
+
require "core/copy"
|
4
|
+
require "core/inspect"
|
7
5
|
|
8
6
|
module Core
|
9
7
|
module Boundary
|
10
8
|
# [public]
|
11
9
|
#
|
12
10
|
class Validator
|
13
|
-
include
|
14
|
-
include Is::Inspectable
|
11
|
+
include Core::Inspect
|
15
12
|
|
16
|
-
using
|
13
|
+
using Core::Copy
|
17
14
|
|
18
15
|
def initialize
|
19
16
|
@validations = []
|
20
17
|
end
|
21
18
|
|
22
|
-
|
19
|
+
def initialize_copy(...)
|
23
20
|
@validations = @validations.copy
|
21
|
+
|
22
|
+
super
|
24
23
|
end
|
25
24
|
|
26
25
|
# [public]
|
@@ -1,9 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "
|
4
|
-
require "
|
5
|
-
|
6
|
-
require "refine/object/copy"
|
3
|
+
require "core/copy"
|
4
|
+
require "core/inspect"
|
7
5
|
|
8
6
|
require_relative "error"
|
9
7
|
require_relative "result"
|
@@ -14,17 +12,30 @@ module Core
|
|
14
12
|
# [public]
|
15
13
|
#
|
16
14
|
class Verifier
|
17
|
-
include
|
18
|
-
include Is::Inspectable
|
15
|
+
include Core::Inspect
|
19
16
|
|
20
|
-
using
|
17
|
+
using Core::Copy
|
21
18
|
|
22
19
|
def initialize
|
23
20
|
@references = []
|
21
|
+
@verification_modules = []
|
24
22
|
end
|
25
23
|
|
26
|
-
|
24
|
+
def initialize_copy(...)
|
27
25
|
@references = @references.map(&:copy)
|
26
|
+
@verification_modules = @verification_modules.copy
|
27
|
+
|
28
|
+
super
|
29
|
+
end
|
30
|
+
|
31
|
+
# [public]
|
32
|
+
#
|
33
|
+
def verifies_with(verification_module)
|
34
|
+
@references.each do |reference|
|
35
|
+
mixin_verification_module(reference, verification_module)
|
36
|
+
end
|
37
|
+
|
38
|
+
@verification_modules << verification_module
|
28
39
|
end
|
29
40
|
|
30
41
|
# [public]
|
@@ -39,7 +50,7 @@ module Core
|
|
39
50
|
options[:type] = type
|
40
51
|
end
|
41
52
|
|
42
|
-
reference =
|
53
|
+
reference = build_reference(reference, **options)
|
43
54
|
|
44
55
|
if block
|
45
56
|
case block.arity
|
@@ -68,7 +79,7 @@ module Core
|
|
68
79
|
options[:type] = type
|
69
80
|
end
|
70
81
|
|
71
|
-
reference =
|
82
|
+
reference = build_reference(reference, **options)
|
72
83
|
|
73
84
|
if block
|
74
85
|
case block.arity
|
@@ -82,6 +93,22 @@ module Core
|
|
82
93
|
@references << reference
|
83
94
|
end
|
84
95
|
|
96
|
+
private def build_reference(...)
|
97
|
+
Reference.new(...).tap { |reference|
|
98
|
+
mixin_verification_modules(reference)
|
99
|
+
}
|
100
|
+
end
|
101
|
+
|
102
|
+
private def mixin_verification_modules(reference)
|
103
|
+
@verification_modules.each do |verification_module|
|
104
|
+
mixin_verification_module(reference, verification_module)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
private def mixin_verification_module(reference, verification_module)
|
109
|
+
reference.singleton_class.include(verification_module)
|
110
|
+
end
|
111
|
+
|
85
112
|
# [public]
|
86
113
|
#
|
87
114
|
def verify(object, result: result_omitted = true)
|
data/lib/core/boundary.rb
CHANGED
@@ -1,13 +1,113 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "core/extension"
|
4
|
+
require "core/state"
|
5
|
+
|
3
6
|
module Core
|
4
7
|
module Boundary
|
5
8
|
require_relative "boundary/validator"
|
6
9
|
require_relative "boundary/verifier"
|
7
10
|
require_relative "boundary/version"
|
8
11
|
|
9
|
-
|
12
|
+
# This gets around a circular dependency.
|
13
|
+
#
|
14
|
+
require_relative "boundary/behavior/verifiable"
|
15
|
+
Core::Boundary::Reference.include(Core::Boundary::Behavior::Verifiable)
|
16
|
+
|
17
|
+
extend Core::Extension
|
18
|
+
|
19
|
+
extends dependencies: [Core::State]
|
20
|
+
|
21
|
+
extends :definition do
|
22
|
+
# [public]
|
23
|
+
#
|
24
|
+
def boundary(method, default: false, &block)
|
25
|
+
method = method.to_sym
|
26
|
+
|
27
|
+
unless (verifier = __boundary_verifiers__[method])
|
28
|
+
verifier = (__boundary_verifiers__[method] = Core::Boundary::Verifier.new)
|
29
|
+
|
30
|
+
__boundaries_module__.module_eval(<<~CODE, __FILE__, __LINE__ + 1)
|
31
|
+
def #{method}(*arguments, **values, &block)
|
32
|
+
result = self.class.__boundary_verifiers__[#{method.inspect}].verify!(values)
|
33
|
+
|
34
|
+
super(*arguments, **result.values, &block)
|
35
|
+
end
|
36
|
+
CODE
|
37
|
+
end
|
38
|
+
|
39
|
+
if default == true
|
40
|
+
@__default_boundary__verifier__ = method
|
41
|
+
end
|
42
|
+
|
43
|
+
if block
|
44
|
+
case block.arity
|
45
|
+
when 0
|
46
|
+
verifier.instance_eval(&block)
|
47
|
+
else
|
48
|
+
block.call(verifier)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
unless ancestors.include?(__boundaries_module__)
|
53
|
+
prepend(__boundaries_module__)
|
54
|
+
end
|
55
|
+
|
56
|
+
verifier
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
DELEGATED_METHODS = %i[required optional verifies_with].freeze
|
61
|
+
|
62
|
+
extends :definition, prepend: true do
|
63
|
+
def method_missing(name, ...)
|
64
|
+
if delegate_to_default_boundary?(name)
|
65
|
+
__boundary_verifiers__[__default_boundary__verifier__].__send__(name, ...)
|
66
|
+
else
|
67
|
+
super
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def respond_to_missing?(name, ...)
|
72
|
+
delegate_to_default_boundary?(name) || super
|
73
|
+
end
|
74
|
+
|
75
|
+
private def delegate_to_default_boundary?(name)
|
76
|
+
DELEGATED_METHODS.include?(name) && __default_boundary__verifier__
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
extends :definition, :implementation do
|
81
|
+
# [public]
|
82
|
+
#
|
83
|
+
def verify(object, &block)
|
84
|
+
build_verifier(&block).verify(object)
|
85
|
+
end
|
86
|
+
|
87
|
+
# [public]
|
88
|
+
#
|
89
|
+
def verify!(object, &block)
|
90
|
+
build_verifier(&block).verify!(object)
|
91
|
+
end
|
92
|
+
|
93
|
+
private def build_verifier(&block)
|
94
|
+
verifier = Core::Boundary::Verifier.new
|
95
|
+
|
96
|
+
case block.arity
|
97
|
+
when 0
|
98
|
+
verifier.instance_eval(&block)
|
99
|
+
else
|
100
|
+
block.call(verifier)
|
101
|
+
end
|
102
|
+
|
103
|
+
verifier
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
applies do
|
108
|
+
state :__default_boundary__verifier__
|
109
|
+
state :__boundaries_module__, default: Module.new
|
110
|
+
state :__boundary_verifiers__, default: {}
|
111
|
+
end
|
10
112
|
end
|
11
113
|
end
|
12
|
-
|
13
|
-
require_relative "../is/boundary"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: core-boundary
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bryan Powell
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-12-
|
11
|
+
date: 2023-12-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: core-copy
|
@@ -16,70 +16,70 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0.
|
19
|
+
version: '0.3'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '0.
|
26
|
+
version: '0.3'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: core-extension
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '0.
|
33
|
+
version: '0.5'
|
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
|
-
version: '0.
|
40
|
+
version: '0.5'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: core-inspect
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '0.
|
47
|
+
version: '0.2'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '0.
|
54
|
+
version: '0.2'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: core-state
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '0.
|
61
|
+
version: '0.2'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '0.
|
68
|
+
version: '0.2'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: core-type
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '0.
|
75
|
+
version: '0.1'
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '0.
|
82
|
+
version: '0.1'
|
83
83
|
description: Define boundaries for verification, validation, and normalization.
|
84
84
|
email: bryan@bryanp.org
|
85
85
|
executables: []
|
@@ -92,7 +92,6 @@ files:
|
|
92
92
|
- lib/core/boundary/behavior/normalization.rb
|
93
93
|
- lib/core/boundary/behavior/validation.rb
|
94
94
|
- lib/core/boundary/behavior/verifiable.rb
|
95
|
-
- lib/core/boundary/bootstrap.rb
|
96
95
|
- lib/core/boundary/error.rb
|
97
96
|
- lib/core/boundary/errors.rb
|
98
97
|
- lib/core/boundary/normalizer.rb
|
@@ -101,7 +100,6 @@ files:
|
|
101
100
|
- lib/core/boundary/validator.rb
|
102
101
|
- lib/core/boundary/verifier.rb
|
103
102
|
- lib/core/boundary/version.rb
|
104
|
-
- lib/is/boundary.rb
|
105
103
|
homepage: https://github.com/bryanp/corerb/
|
106
104
|
licenses:
|
107
105
|
- MPL-2.0
|
data/lib/is/boundary.rb
DELETED
@@ -1,109 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "is/extension"
|
4
|
-
require "is/stateful"
|
5
|
-
|
6
|
-
require_relative "../core/boundary/verifier"
|
7
|
-
require_relative "../core/boundary/bootstrap"
|
8
|
-
|
9
|
-
module Is
|
10
|
-
# [public]
|
11
|
-
#
|
12
|
-
module Boundary
|
13
|
-
extend Is::Extension
|
14
|
-
|
15
|
-
extends dependencies: [Is::Stateful]
|
16
|
-
|
17
|
-
extends :definition do
|
18
|
-
# [public]
|
19
|
-
#
|
20
|
-
def boundary(method, default: false, &block)
|
21
|
-
method = method.to_sym
|
22
|
-
|
23
|
-
unless (verifier = __boundary_verifiers__[method])
|
24
|
-
verifier = (__boundary_verifiers__[method] = Core::Boundary::Verifier.new)
|
25
|
-
|
26
|
-
__boundaries_module__.module_eval(<<~CODE, __FILE__, __LINE__ + 1)
|
27
|
-
def #{method}(*arguments, **values, &block)
|
28
|
-
result = self.class.__boundary_verifiers__[#{method.inspect}].verify!(values)
|
29
|
-
|
30
|
-
super(*arguments, **result.values, &block)
|
31
|
-
end
|
32
|
-
CODE
|
33
|
-
end
|
34
|
-
|
35
|
-
if default == true
|
36
|
-
@__default_boundary__verifier__ = method
|
37
|
-
end
|
38
|
-
|
39
|
-
if block
|
40
|
-
case block.arity
|
41
|
-
when 0
|
42
|
-
verifier.instance_eval(&block)
|
43
|
-
else
|
44
|
-
block.call(verifier)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
unless ancestors.include?(__boundaries_module__)
|
49
|
-
prepend(__boundaries_module__)
|
50
|
-
end
|
51
|
-
|
52
|
-
verifier
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
DELEGATED_METHODS = %i[required optional].freeze
|
57
|
-
|
58
|
-
extends :definition, prepend: true do
|
59
|
-
def method_missing(name, ...)
|
60
|
-
if delegate_to_default_boundary?(name)
|
61
|
-
__boundary_verifiers__[__default_boundary__verifier__].__send__(name, ...)
|
62
|
-
else
|
63
|
-
super
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
def respond_to_missing?(name, ...)
|
68
|
-
delegate_to_default_boundary?(name) || super
|
69
|
-
end
|
70
|
-
|
71
|
-
private def delegate_to_default_boundary?(name)
|
72
|
-
DELEGATED_METHODS.include?(name) && __default_boundary__verifier__
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
extends :definition, :implementation do
|
77
|
-
# [public]
|
78
|
-
#
|
79
|
-
def verify(object, &block)
|
80
|
-
build_verifier(&block).verify(object)
|
81
|
-
end
|
82
|
-
|
83
|
-
# [public]
|
84
|
-
#
|
85
|
-
def verify!(object, &block)
|
86
|
-
build_verifier(&block).verify!(object)
|
87
|
-
end
|
88
|
-
|
89
|
-
private def build_verifier(&block)
|
90
|
-
verifier = Core::Boundary::Verifier.new
|
91
|
-
|
92
|
-
case block.arity
|
93
|
-
when 0
|
94
|
-
verifier.instance_eval(&block)
|
95
|
-
else
|
96
|
-
block.call(verifier)
|
97
|
-
end
|
98
|
-
|
99
|
-
verifier
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
applies do
|
104
|
-
state :__default_boundary__verifier__
|
105
|
-
state :__boundaries_module__, default: Module.new
|
106
|
-
state :__boundary_verifiers__, default: {}
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|