1
1
defmodule JS2E.Printers.OneOfPrinter do
2
+ @ behaviour JS2E.Printers.PrinterBehaviour
2
3
@ moduledoc """
3
4
A printer for printing a 'one of' type decoder.
4
5
"""
@@ -22,11 +23,9 @@ defmodule JS2E.Printers.OneOfPrinter do
22
23
EEx . function_from_file ( :defp , :encoder_template , @ encoder_location ,
23
24
[ :encoder_name , :type_name , :argument_name , :cases ] )
24
25
25
- @ spec print_type (
26
- Types . typeDefinition ,
27
- SchemaDefinition . t ,
28
- Types . schemaDictionary
29
- ) :: String . t
26
+ @ impl JS2E.Printers.PrinterBehaviour
27
+ @ spec print_type ( Types . typeDefinition , SchemaDefinition . t ,
28
+ Types . schemaDictionary ) :: String . t
30
29
def print_type ( % OneOfType { name: name ,
31
30
path: _path ,
32
31
types: types } , schema_def , schema_dict ) do
@@ -48,7 +47,7 @@ defmodule JS2E.Printers.OneOfPrinter do
48
47
type_name = upcase_first name
49
48
50
49
create_type_clause = fn type_path ->
51
- { clause_type , resolved_schema_def } =
50
+ { clause_type , _resolved_schema_def } =
52
51
type_path
53
52
|> Printer . resolve_type! ( schema_def , schema_dict )
54
53
@@ -67,11 +66,9 @@ defmodule JS2E.Printers.OneOfPrinter do
67
66
|> Enum . map ( create_type_clause )
68
67
end
69
68
70
- @ spec print_decoder (
71
- Types . typeDefinition ,
72
- SchemaDefinition . t ,
73
- Types . schemaDictionary
74
- ) :: String . t
69
+ @ impl JS2E.Printers.PrinterBehaviour
70
+ @ spec print_decoder ( Types . typeDefinition , SchemaDefinition . t ,
71
+ Types . schemaDictionary ) :: String . t
75
72
def print_decoder ( % OneOfType { name: name ,
76
73
path: _path ,
77
74
types: types } , schema_def , schema_dict ) do
@@ -91,7 +88,7 @@ defmodule JS2E.Printers.OneOfPrinter do
91
88
defp create_decoder_clauses ( types , schema_def , schema_dict ) do
92
89
93
90
create_decoder_clause = fn type_path ->
94
- { clause_type , resolved_schema_def } =
91
+ { clause_type , _resolved_schema_def } =
95
92
type_path
96
93
|> Printer . resolve_type! ( schema_def , schema_dict )
97
94
@@ -102,11 +99,9 @@ defmodule JS2E.Printers.OneOfPrinter do
102
99
|> Enum . map ( create_decoder_clause )
103
100
end
104
101
105
- @ spec print_encoder (
106
- Types . typeDefinition ,
107
- SchemaDefinition . t ,
108
- Types . schemaDictionary
109
- ) :: String . t
102
+ @ impl JS2E.Printers.PrinterBehaviour
103
+ @ spec print_encoder ( Types . typeDefinition , SchemaDefinition . t ,
104
+ Types . schemaDictionary ) :: String . t
110
105
def print_encoder ( % OneOfType { name: name ,
111
106
path: _path ,
112
107
types: types } , schema_def , schema_dict ) do
@@ -143,7 +138,7 @@ defmodule JS2E.Printers.OneOfPrinter do
143
138
type_name = upcase_first name
144
139
145
140
create_type_clause = fn type_path ->
146
- { clause_type , resolved_schema_def } =
141
+ { clause_type , _resolved_schema_def } =
147
142
type_path
148
143
|> Printer . resolve_type! ( schema_def , schema_dict )
149
144
0 commit comments