File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,8 @@ def rule_config
26
26
self . input_types
27
27
when :return_type
28
28
self . return_type
29
+ when :parent_type
30
+ self . parent_type
29
31
else
30
32
raise UnexpectedRuleType , "Unknown rule type #{ variant } "
31
33
end
@@ -47,6 +49,8 @@ def create(variant, config)
47
49
self . input_types = DefinitionDataTypeInputTypesRuleConfig . new ( config )
48
50
when :return_type
49
51
self . return_type = DefinitionDataTypeReturnTypeRuleConfig . new ( config )
52
+ when :parent_type
53
+ self . parent_type = DefinitionDataTypeParentTypeRuleConfig . new ( config )
50
54
else
51
55
raise UnexpectedRuleType , "Unknown rule type #{ variant } "
52
56
end
@@ -159,6 +163,18 @@ def self.from_hash(config)
159
163
end
160
164
end
161
165
166
+ DefinitionDataTypeParentTypeRuleConfig . class_eval do
167
+ def to_h
168
+ {
169
+ parent_type : self . parent_type ,
170
+ }
171
+ end
172
+
173
+ def self . from_hash ( config )
174
+ new ( parent_type : DataTypeIdentifier . from_hash ( config [ :parent_type ] ) )
175
+ end
176
+ end
177
+
162
178
DataTypeIdentifier . class_eval do
163
179
def to_h
164
180
{
Original file line number Diff line number Diff line change 60
60
end
61
61
end
62
62
63
+ context "with :parent_type variant" do
64
+ it "sets the parent_type field" do
65
+ config = { parent_type : { data_type_identifier : "test_type" } }
66
+ rule = described_class . create ( :parent_type , config )
67
+ expect ( rule . parent_type ) . to be_a ( Tucana ::Shared ::DefinitionDataTypeParentTypeRuleConfig )
68
+ end
69
+ end
70
+
63
71
context "with unknown variant" do
64
72
it "raises UnexpectedRuleType error" do
65
73
expect {
You can’t perform that action at this time.
0 commit comments