treaty 0.6.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +9 -4
- data/config/locales/en.yml +6 -4
- data/lib/treaty/attribute/base.rb +15 -7
- data/lib/treaty/attribute/builder/base.rb +4 -4
- data/lib/treaty/attribute/collection.rb +1 -1
- data/lib/treaty/attribute/dsl.rb +90 -0
- data/lib/treaty/attribute/entity/attribute.rb +25 -0
- data/lib/treaty/attribute/entity/builder.rb +23 -0
- data/lib/treaty/attribute/option/base.rb +17 -1
- data/lib/treaty/attribute/option/modifiers/as_modifier.rb +5 -3
- data/lib/treaty/attribute/option/modifiers/default_modifier.rb +1 -1
- data/lib/treaty/attribute/option/registry.rb +4 -4
- data/lib/treaty/attribute/option/validators/inclusion_validator.rb +20 -8
- data/lib/treaty/attribute/option/validators/required_validator.rb +8 -2
- data/lib/treaty/attribute/option/validators/type_validator.rb +51 -40
- data/lib/treaty/attribute/option_orchestrator.rb +8 -6
- data/lib/treaty/attribute/validation/nested_array_validator.rb +21 -15
- data/lib/treaty/attribute/validation/nested_transformer.rb +24 -18
- data/lib/treaty/attribute/validation/orchestrator/base.rb +67 -83
- data/lib/treaty/base.rb +1 -1
- data/lib/treaty/controller/dsl.rb +4 -1
- data/lib/treaty/entity.rb +84 -0
- data/lib/treaty/exceptions/nested_attributes.rb +2 -2
- data/lib/treaty/info/entity/builder.rb +50 -0
- data/lib/treaty/info/entity/dsl.rb +28 -0
- data/lib/treaty/info/entity/result.rb +15 -0
- data/lib/treaty/info/rest/builder.rb +110 -0
- data/lib/treaty/info/rest/dsl.rb +28 -0
- data/lib/treaty/info/rest/result.rb +15 -0
- data/lib/treaty/request/attribute/attribute.rb +1 -0
- data/lib/treaty/request/attribute/builder.rb +1 -0
- data/lib/treaty/request/entity.rb +33 -0
- data/lib/treaty/request/factory.rb +63 -14
- data/lib/treaty/request/validator.rb +65 -0
- data/lib/treaty/response/attribute/attribute.rb +1 -0
- data/lib/treaty/response/attribute/builder.rb +1 -0
- data/lib/treaty/response/entity.rb +33 -0
- data/lib/treaty/response/factory.rb +63 -14
- data/lib/treaty/response/validator.rb +57 -0
- data/lib/treaty/version.rb +1 -1
- data/lib/treaty/versions/execution/request.rb +10 -5
- data/lib/treaty/versions/factory.rb +16 -5
- data/lib/treaty/versions/resolver.rb +8 -2
- data/lib/treaty/versions/workspace.rb +2 -2
- metadata +15 -12
- data/lib/treaty/info/builder.rb +0 -122
- data/lib/treaty/info/dsl.rb +0 -26
- data/lib/treaty/info/result.rb +0 -13
- data/lib/treaty/request/attribute/validation/orchestrator.rb +0 -27
- data/lib/treaty/request/attribute/validator.rb +0 -50
- data/lib/treaty/request/scope/collection.rb +0 -21
- data/lib/treaty/request/scope/factory.rb +0 -42
- data/lib/treaty/response/attribute/validation/orchestrator.rb +0 -27
- data/lib/treaty/response/attribute/validator.rb +0 -44
- data/lib/treaty/response/scope/collection.rb +0 -21
- data/lib/treaty/response/scope/factory.rb +0 -42
|
@@ -13,7 +13,7 @@ module Treaty
|
|
|
13
13
|
collection_of_versions: @collection_of_versions
|
|
14
14
|
)
|
|
15
15
|
|
|
16
|
-
validated_params = Request::
|
|
16
|
+
validated_params = Request::Validator.validate!(
|
|
17
17
|
params:,
|
|
18
18
|
version_factory:
|
|
19
19
|
)
|
|
@@ -23,7 +23,7 @@ module Treaty
|
|
|
23
23
|
validated_params:
|
|
24
24
|
)
|
|
25
25
|
|
|
26
|
-
validated_response = Response::
|
|
26
|
+
validated_response = Response::Validator.validate!(
|
|
27
27
|
version_factory:,
|
|
28
28
|
response_data: executor_result
|
|
29
29
|
)
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: treaty
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.8.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Anton Sokolov
|
|
@@ -150,6 +150,9 @@ files:
|
|
|
150
150
|
- lib/treaty/attribute/base.rb
|
|
151
151
|
- lib/treaty/attribute/builder/base.rb
|
|
152
152
|
- lib/treaty/attribute/collection.rb
|
|
153
|
+
- lib/treaty/attribute/dsl.rb
|
|
154
|
+
- lib/treaty/attribute/entity/attribute.rb
|
|
155
|
+
- lib/treaty/attribute/entity/builder.rb
|
|
153
156
|
- lib/treaty/attribute/helper_mapper.rb
|
|
154
157
|
- lib/treaty/attribute/option/base.rb
|
|
155
158
|
- lib/treaty/attribute/option/modifiers/as_modifier.rb
|
|
@@ -174,6 +177,7 @@ files:
|
|
|
174
177
|
- lib/treaty/context/workspace.rb
|
|
175
178
|
- lib/treaty/controller/dsl.rb
|
|
176
179
|
- lib/treaty/engine.rb
|
|
180
|
+
- lib/treaty/entity.rb
|
|
177
181
|
- lib/treaty/exceptions/base.rb
|
|
178
182
|
- lib/treaty/exceptions/class_name.rb
|
|
179
183
|
- lib/treaty/exceptions/deprecated.rb
|
|
@@ -184,23 +188,22 @@ files:
|
|
|
184
188
|
- lib/treaty/exceptions/strategy.rb
|
|
185
189
|
- lib/treaty/exceptions/unexpected.rb
|
|
186
190
|
- lib/treaty/exceptions/validation.rb
|
|
187
|
-
- lib/treaty/info/builder.rb
|
|
188
|
-
- lib/treaty/info/dsl.rb
|
|
189
|
-
- lib/treaty/info/result.rb
|
|
191
|
+
- lib/treaty/info/entity/builder.rb
|
|
192
|
+
- lib/treaty/info/entity/dsl.rb
|
|
193
|
+
- lib/treaty/info/entity/result.rb
|
|
194
|
+
- lib/treaty/info/rest/builder.rb
|
|
195
|
+
- lib/treaty/info/rest/dsl.rb
|
|
196
|
+
- lib/treaty/info/rest/result.rb
|
|
190
197
|
- lib/treaty/request/attribute/attribute.rb
|
|
191
198
|
- lib/treaty/request/attribute/builder.rb
|
|
192
|
-
- lib/treaty/request/
|
|
193
|
-
- lib/treaty/request/attribute/validator.rb
|
|
199
|
+
- lib/treaty/request/entity.rb
|
|
194
200
|
- lib/treaty/request/factory.rb
|
|
195
|
-
- lib/treaty/request/
|
|
196
|
-
- lib/treaty/request/scope/factory.rb
|
|
201
|
+
- lib/treaty/request/validator.rb
|
|
197
202
|
- lib/treaty/response/attribute/attribute.rb
|
|
198
203
|
- lib/treaty/response/attribute/builder.rb
|
|
199
|
-
- lib/treaty/response/
|
|
200
|
-
- lib/treaty/response/attribute/validator.rb
|
|
204
|
+
- lib/treaty/response/entity.rb
|
|
201
205
|
- lib/treaty/response/factory.rb
|
|
202
|
-
- lib/treaty/response/
|
|
203
|
-
- lib/treaty/response/scope/factory.rb
|
|
206
|
+
- lib/treaty/response/validator.rb
|
|
204
207
|
- lib/treaty/result.rb
|
|
205
208
|
- lib/treaty/strategy.rb
|
|
206
209
|
- lib/treaty/support/loader.rb
|
data/lib/treaty/info/builder.rb
DELETED
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Treaty
|
|
4
|
-
module Info
|
|
5
|
-
class Builder
|
|
6
|
-
attr_reader :versions
|
|
7
|
-
|
|
8
|
-
def self.build(...)
|
|
9
|
-
new.build(...)
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def build(collection_of_versions:)
|
|
13
|
-
build_all(
|
|
14
|
-
versions: collection_of_versions
|
|
15
|
-
)
|
|
16
|
-
|
|
17
|
-
self
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
private
|
|
21
|
-
|
|
22
|
-
def build_all(versions:)
|
|
23
|
-
build_versions_with(
|
|
24
|
-
collection: versions
|
|
25
|
-
)
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
##########################################################################
|
|
29
|
-
|
|
30
|
-
def build_versions_with(collection:) # rubocop:disable Metrics/MethodLength
|
|
31
|
-
@versions = collection.map do |version|
|
|
32
|
-
gem_version = version.version.version
|
|
33
|
-
{
|
|
34
|
-
version: gem_version.version,
|
|
35
|
-
segments: gem_version.segments,
|
|
36
|
-
default: version.default_result,
|
|
37
|
-
summary: version.summary_text,
|
|
38
|
-
strategy: version.strategy_instance.code,
|
|
39
|
-
deprecated: version.deprecated_result,
|
|
40
|
-
executor: build_executor_with(version),
|
|
41
|
-
request: build_request_with(version),
|
|
42
|
-
response: build_response_with(version)
|
|
43
|
-
}
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
##########################################################################
|
|
48
|
-
|
|
49
|
-
def build_executor_with(version)
|
|
50
|
-
{
|
|
51
|
-
executor: version.executor.executor,
|
|
52
|
-
method: version.executor.method
|
|
53
|
-
}
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
##########################################################################
|
|
57
|
-
|
|
58
|
-
def build_request_with(version)
|
|
59
|
-
{
|
|
60
|
-
scopes: build_scopes_with(version.request_factory)
|
|
61
|
-
}
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
def build_response_with(version)
|
|
65
|
-
response_factory = version.response_factory
|
|
66
|
-
{
|
|
67
|
-
status: response_factory.status,
|
|
68
|
-
scopes: build_scopes_with(response_factory)
|
|
69
|
-
}
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
##########################################################################
|
|
73
|
-
|
|
74
|
-
def build_scopes_with(request_factory)
|
|
75
|
-
request_factory.collection_of_scopes.to_h do |scope|
|
|
76
|
-
[
|
|
77
|
-
scope.name,
|
|
78
|
-
build_attributes_with(scope.collection_of_attributes)
|
|
79
|
-
]
|
|
80
|
-
end
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
##########################################################################
|
|
84
|
-
|
|
85
|
-
def build_attributes_with(collection, current_level = 0)
|
|
86
|
-
# validate_nesting_level!(current_level)
|
|
87
|
-
|
|
88
|
-
{
|
|
89
|
-
attributes: build_attributes_hash(collection, current_level)
|
|
90
|
-
}
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
def build_attributes_hash(collection, current_level)
|
|
94
|
-
collection.to_h do |attribute|
|
|
95
|
-
[
|
|
96
|
-
attribute.name,
|
|
97
|
-
{
|
|
98
|
-
type: attribute.type,
|
|
99
|
-
options: attribute.options,
|
|
100
|
-
attributes: build_nested_attributes(attribute, current_level)
|
|
101
|
-
}
|
|
102
|
-
]
|
|
103
|
-
end
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
def build_nested_attributes(attribute, current_level)
|
|
107
|
-
return {} unless attribute.nested?
|
|
108
|
-
|
|
109
|
-
build_attributes_hash(attribute.collection_of_attributes, current_level + 1)
|
|
110
|
-
end
|
|
111
|
-
|
|
112
|
-
# def validate_nesting_level!(level)
|
|
113
|
-
# return unless level > Treaty::Engine.config.treaty.attribute_nesting_level
|
|
114
|
-
#
|
|
115
|
-
# raise Treaty::Exceptions::NestedAttributes,
|
|
116
|
-
# I18n.t("treaty.attributes.errors.nesting_level_exceeded",
|
|
117
|
-
# level:,
|
|
118
|
-
# max_level: Treaty::Engine.config.treaty.attribute_nesting_level)
|
|
119
|
-
# end
|
|
120
|
-
end
|
|
121
|
-
end
|
|
122
|
-
end
|
data/lib/treaty/info/dsl.rb
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Treaty
|
|
4
|
-
module Info
|
|
5
|
-
module DSL
|
|
6
|
-
def self.included(base)
|
|
7
|
-
base.extend(ClassMethods)
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
module ClassMethods
|
|
11
|
-
def info
|
|
12
|
-
builder = Builder.build(
|
|
13
|
-
collection_of_versions:
|
|
14
|
-
)
|
|
15
|
-
|
|
16
|
-
Result.new(builder)
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
# API: Treaty Web
|
|
20
|
-
def treaty?
|
|
21
|
-
true
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|
data/lib/treaty/info/result.rb
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Treaty
|
|
4
|
-
module Request
|
|
5
|
-
module Attribute
|
|
6
|
-
module Validation
|
|
7
|
-
class Orchestrator < Treaty::Attribute::Validation::Orchestrator::Base
|
|
8
|
-
private
|
|
9
|
-
|
|
10
|
-
def collection_of_scopes
|
|
11
|
-
return Treaty::Request::Scope::Collection.new if version_factory.request_factory.nil?
|
|
12
|
-
|
|
13
|
-
version_factory.request_factory.collection_of_scopes
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def scope_data_for(name)
|
|
17
|
-
# If the scope is :_self, it's the root level.
|
|
18
|
-
return data if name == :_self
|
|
19
|
-
|
|
20
|
-
# Otherwise, fetch data from the named scope.
|
|
21
|
-
data.fetch(name, {})
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
end
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Treaty
|
|
4
|
-
module Request
|
|
5
|
-
module Attribute
|
|
6
|
-
class Validator < Treaty::Attribute::Validation::Base
|
|
7
|
-
def self.validate!(...)
|
|
8
|
-
new(...).validate!
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
def initialize(params:, version_factory:)
|
|
12
|
-
super(version_factory:)
|
|
13
|
-
|
|
14
|
-
@params = params
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def validate!
|
|
18
|
-
validate_request_attributes!
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
private
|
|
22
|
-
|
|
23
|
-
def request_data
|
|
24
|
-
@request_data ||= begin
|
|
25
|
-
@params.to_unsafe_h
|
|
26
|
-
rescue NoMethodError
|
|
27
|
-
@params
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
def validate_request_attributes!
|
|
32
|
-
return request_data unless adapter_strategy?
|
|
33
|
-
return request_data unless request_attributes_exist?
|
|
34
|
-
|
|
35
|
-
# For adapter strategy:
|
|
36
|
-
Validation::Orchestrator.validate!(
|
|
37
|
-
version_factory: @version_factory,
|
|
38
|
-
data: request_data
|
|
39
|
-
)
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
def request_attributes_exist?
|
|
43
|
-
return false if @version_factory.request_factory&.collection_of_scopes&.empty?
|
|
44
|
-
|
|
45
|
-
@version_factory.request_factory.collection_of_scopes.exists?
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
end
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Treaty
|
|
4
|
-
module Request
|
|
5
|
-
module Scope
|
|
6
|
-
class Collection
|
|
7
|
-
extend Forwardable
|
|
8
|
-
|
|
9
|
-
def_delegators :@collection, :<<, :to_h, :each, :find, :empty?
|
|
10
|
-
|
|
11
|
-
def initialize(collection = Set.new)
|
|
12
|
-
@collection = collection
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def exists?
|
|
16
|
-
!empty?
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
end
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Treaty
|
|
4
|
-
module Request
|
|
5
|
-
module Scope
|
|
6
|
-
class Factory
|
|
7
|
-
attr_reader :name
|
|
8
|
-
|
|
9
|
-
def initialize(name)
|
|
10
|
-
@name = name
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def attribute(name, type, *helpers, **options, &block)
|
|
14
|
-
collection_of_attributes << Attribute::Attribute.new(
|
|
15
|
-
name,
|
|
16
|
-
type,
|
|
17
|
-
*helpers,
|
|
18
|
-
nesting_level: 0,
|
|
19
|
-
**options,
|
|
20
|
-
&block
|
|
21
|
-
)
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def collection_of_attributes
|
|
25
|
-
@collection_of_attributes ||= Treaty::Attribute::Collection.new
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
########################################################################
|
|
29
|
-
|
|
30
|
-
def method_missing(type, *helpers, **options, &block)
|
|
31
|
-
name = helpers.shift
|
|
32
|
-
|
|
33
|
-
attribute(name, type, *helpers, **options, &block)
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
def respond_to_missing?(name, *)
|
|
37
|
-
super
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
end
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Treaty
|
|
4
|
-
module Response
|
|
5
|
-
module Attribute
|
|
6
|
-
module Validation
|
|
7
|
-
class Orchestrator < Treaty::Attribute::Validation::Orchestrator::Base
|
|
8
|
-
private
|
|
9
|
-
|
|
10
|
-
def collection_of_scopes
|
|
11
|
-
return Treaty::Response::Scope::Collection.new if version_factory.response_factory.nil?
|
|
12
|
-
|
|
13
|
-
version_factory.response_factory.collection_of_scopes
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def scope_data_for(name)
|
|
17
|
-
# If the scope is :_self, it's the root level.
|
|
18
|
-
return data if name == :_self
|
|
19
|
-
|
|
20
|
-
# Otherwise, fetch data from the named scope.
|
|
21
|
-
data.fetch(name, {})
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
end
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Treaty
|
|
4
|
-
module Response
|
|
5
|
-
module Attribute
|
|
6
|
-
class Validator < Treaty::Attribute::Validation::Base
|
|
7
|
-
def self.validate!(version_factory:, response_data: {})
|
|
8
|
-
new(
|
|
9
|
-
version_factory:,
|
|
10
|
-
response_data:
|
|
11
|
-
).validate!
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def initialize(version_factory:, response_data: {})
|
|
15
|
-
super(version_factory:)
|
|
16
|
-
|
|
17
|
-
@response_data = response_data
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def validate!
|
|
21
|
-
validate_response_attributes!
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
private
|
|
25
|
-
|
|
26
|
-
def validate_response_attributes!
|
|
27
|
-
return @response_data unless response_attributes_exist?
|
|
28
|
-
|
|
29
|
-
# For adapter strategy:
|
|
30
|
-
Validation::Orchestrator.validate!(
|
|
31
|
-
version_factory: @version_factory,
|
|
32
|
-
data: @response_data
|
|
33
|
-
)
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
def response_attributes_exist?
|
|
37
|
-
return false if @version_factory.response_factory&.collection_of_scopes&.empty?
|
|
38
|
-
|
|
39
|
-
@version_factory.response_factory.collection_of_scopes.exists?
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
end
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Treaty
|
|
4
|
-
module Response
|
|
5
|
-
module Scope
|
|
6
|
-
class Collection
|
|
7
|
-
extend Forwardable
|
|
8
|
-
|
|
9
|
-
def_delegators :@collection, :<<, :to_h, :each, :find, :empty?
|
|
10
|
-
|
|
11
|
-
def initialize(collection = Set.new)
|
|
12
|
-
@collection = collection
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def exists?
|
|
16
|
-
!empty?
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
end
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Treaty
|
|
4
|
-
module Response
|
|
5
|
-
module Scope
|
|
6
|
-
class Factory
|
|
7
|
-
attr_reader :name
|
|
8
|
-
|
|
9
|
-
def initialize(name)
|
|
10
|
-
@name = name
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def attribute(name, type, *helpers, **options, &block)
|
|
14
|
-
collection_of_attributes << Attribute::Attribute.new(
|
|
15
|
-
name,
|
|
16
|
-
type,
|
|
17
|
-
*helpers,
|
|
18
|
-
nesting_level: 0,
|
|
19
|
-
**options,
|
|
20
|
-
&block
|
|
21
|
-
)
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def collection_of_attributes
|
|
25
|
-
@collection_of_attributes ||= Treaty::Attribute::Collection.new
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
########################################################################
|
|
29
|
-
|
|
30
|
-
def method_missing(type, *helpers, **options, &block)
|
|
31
|
-
name = helpers.shift
|
|
32
|
-
|
|
33
|
-
attribute(name, type, *helpers, **options, &block)
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
def respond_to_missing?(name, *)
|
|
37
|
-
super
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
end
|