datory 1.0.0.rc22 → 1.0.0.rc23
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/config/locales/en.yml +37 -35
- data/config/locales/ru.yml +38 -36
- data/lib/datory/attributes/attribute.rb +8 -3
- data/lib/datory/attributes/dsl.rb +140 -20
- data/lib/datory/attributes/options/to.rb +4 -2
- data/lib/datory/attributes/workspace.rb +2 -0
- data/lib/datory/service/builder.rb +14 -5
- data/lib/datory/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9747b4b3a2f48901f80ea6a11b8dbe4639e525b63d1cd33a858128f6ed0f38ad
|
|
4
|
+
data.tar.gz: 2da18e0eee1aff2ec5c15babc2f0a2888895d3ead07839c28a98b590c7a947a1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1ff4c2fd4556f1ae832e0fc17b15145a3fa55bf663daafbbdda9ad9209d8c3089a36cf0fcf458399d629b0086511671f3da7823d7d964257fd16d68d8898ad29
|
|
7
|
+
data.tar.gz: d216ec59daa6217b2681dd0063b37582953e464e742c791d38bf37e6e565ddd15db914f944178764fc30a5e66be60c392a04cc1defedba554851b9c044f62d74
|
data/config/locales/en.yml
CHANGED
|
@@ -9,40 +9,40 @@ en:
|
|
|
9
9
|
cannot_be_overwritten: "[%{service_class_name}] The following methods cannot be overwritten: %{list_of_methods}"
|
|
10
10
|
inputs:
|
|
11
11
|
undefined:
|
|
12
|
-
getter: "[%{service_class_name}] Undefined
|
|
13
|
-
setter: "[%{service_class_name}] Undefined
|
|
12
|
+
getter: "[%{service_class_name}] Undefined serialization attribute `%{input_name}`"
|
|
13
|
+
setter: "[%{service_class_name}] Undefined serialization attribute `%{input_name}`"
|
|
14
14
|
validations:
|
|
15
15
|
inclusion:
|
|
16
16
|
default_error: "[%{service_class_name}] Wrong value in `%{input_name}`, must be one of `%{input_inclusion}`"
|
|
17
17
|
must:
|
|
18
|
-
default_error: "[%{service_class_name}]
|
|
19
|
-
syntax_error: "[%{service_class_name}] Syntax error inside `%{code}` of `%{input_name}`
|
|
18
|
+
default_error: "[%{service_class_name}] Serialization attribute `%{input_name}` must \"%{code}\""
|
|
19
|
+
syntax_error: "[%{service_class_name}] Syntax error inside `%{code}` of `%{input_name}` serialization attribute: %{exception_message}"
|
|
20
20
|
dynamic_options:
|
|
21
|
+
consists_of:
|
|
22
|
+
required: "[%{service_class_name}] Required element in serialization attribute collection `%{input_name}` is missing"
|
|
23
|
+
wrong_type: "[%{service_class_name}] Wrong serialization attribute collection type `%{input_name}`, expected `%{expected_type}`, got `%{given_type}`"
|
|
24
|
+
wrong_element_type: "[%{service_class_name}] Wrong element type in serialization attribute collection `%{input_name}`, expected `%{expected_type}`, got `%{given_type}`"
|
|
21
25
|
format:
|
|
22
|
-
default: "[%{service_class_name}]
|
|
23
|
-
wrong_pattern: "[%{service_class_name}]
|
|
24
|
-
unknown: "[%{service_class_name}] Unknown `%{format_name}` format specified for
|
|
26
|
+
default: "[%{service_class_name}] Serialization attribute `%{input_name}` does not match `%{format_name}` format"
|
|
27
|
+
wrong_pattern: "[%{service_class_name}] Serialization attribute `%{input_name}` does not match `%{format_name}` format"
|
|
28
|
+
unknown: "[%{service_class_name}] Unknown `%{format_name}` format specified for serialization attribute `%{input_name}`"
|
|
25
29
|
min:
|
|
26
|
-
default: "[%{service_class_name}]
|
|
30
|
+
default: "[%{service_class_name}] Serialization attribute `%{input_name}` received value `%{value}`, which is less than `%{option_value}`"
|
|
27
31
|
max:
|
|
28
|
-
default: "[%{service_class_name}]
|
|
32
|
+
default: "[%{service_class_name}] Serialization attribute `%{input_name}` received value `%{value}`, which is greater than `%{option_value}`"
|
|
29
33
|
required:
|
|
30
34
|
default_error:
|
|
31
|
-
default: "[%{service_class_name}] Required
|
|
32
|
-
for_collection: "[%{service_class_name}] Required element in input collection `%{input_name}` is missing"
|
|
35
|
+
default: "[%{service_class_name}] Required serialization attribute `%{input_name}` is missing"
|
|
33
36
|
type:
|
|
34
37
|
default_error:
|
|
35
|
-
default: "[%{service_class_name}] Wrong type of
|
|
36
|
-
for_collection:
|
|
37
|
-
wrong_type: "[%{service_class_name}] Wrong input collection type `%{input_name}`, expected `%{expected_type}`, got `%{given_type}`"
|
|
38
|
-
wrong_element_type: "[%{service_class_name}] Wrong type in input collection `%{input_name}`, expected `%{expected_type}`, got `%{given_type}`"
|
|
38
|
+
default: "[%{service_class_name}] Wrong type of serialization attribute `%{input_name}`, expected `%{expected_type}`, got `%{given_type}`"
|
|
39
39
|
for_hash:
|
|
40
|
-
wrong_element_type: "[%{service_class_name}] Wrong type in
|
|
40
|
+
wrong_element_type: "[%{service_class_name}] Wrong type in serialization attribute hash `%{input_name}`, expected `%{expected_type}` for `%{key_name}`, got `%{given_type}`"
|
|
41
41
|
tools:
|
|
42
42
|
find_unnecessary:
|
|
43
43
|
error: "[%{service_class_name}] Unexpected attributes: `%{unnecessary_attributes}`"
|
|
44
44
|
rules:
|
|
45
|
-
error: "[%{service_class_name}] Conflict in `%{input_name}`
|
|
45
|
+
error: "[%{service_class_name}] Conflict in `%{input_name}` serialization attribute options: `%{conflict_code}`"
|
|
46
46
|
internals:
|
|
47
47
|
undefined:
|
|
48
48
|
getter: "[%{service_class_name}] Undefined internal attribute `%{internal_name}`"
|
|
@@ -54,10 +54,14 @@ en:
|
|
|
54
54
|
default_error: "[%{service_class_name}] Internal attribute `%{internal_name}` must \"%{code}\""
|
|
55
55
|
syntax_error: "[%{service_class_name}] Syntax error inside `%{code}` of `%{internal_name}` internal attribute: %{exception_message}"
|
|
56
56
|
dynamic_options:
|
|
57
|
+
consists_of:
|
|
58
|
+
required: "[%{service_class_name}] Required element in internal attribute collection `%{internal_name}` is missing"
|
|
59
|
+
wrong_type: "[%{service_class_name}] Wrong internal attribute collection type `%{internal_name}`, expected `%{expected_type}`, got `%{given_type}`"
|
|
60
|
+
wrong_element_type: "[%{service_class_name}] Wrong element type in internal attribute collection `%{internal_name}`, expected `%{expected_type}`, got `%{given_type}`"
|
|
57
61
|
format:
|
|
58
62
|
default: "[%{service_class_name}] Internal attribute `%{internal_name}` does not match `%{format_name}` format"
|
|
59
63
|
wrong_pattern: "[%{service_class_name}] Internal attribute `%{internal_name}` does not match `%{format_name}` format"
|
|
60
|
-
unknown: "[%{service_class_name}] Unknown `%{format_name}` format specified for
|
|
64
|
+
unknown: "[%{service_class_name}] Unknown `%{format_name}` format specified for internal attribute `%{internal_name}`"
|
|
61
65
|
min:
|
|
62
66
|
default: "[%{service_class_name}] Internal attribute `%{internal_name}` received value `%{value}`, which is less than `%{option_value}`"
|
|
63
67
|
max:
|
|
@@ -65,35 +69,33 @@ en:
|
|
|
65
69
|
type:
|
|
66
70
|
default_error:
|
|
67
71
|
default: "[%{service_class_name}] Wrong type of internal attribute `%{internal_name}`, expected `%{expected_type}`, got `%{given_type}`"
|
|
68
|
-
for_collection:
|
|
69
|
-
wrong_type: "[%{service_class_name}] Wrong internal attribute collection type `%{internal_name}`, expected `%{expected_type}`, got `%{given_type}`"
|
|
70
|
-
wrong_element_type: "[%{service_class_name}] Wrong element type in internal attribute collection `%{internal_name}`, expected `%{expected_type}`, got `%{given_type}`"
|
|
71
72
|
for_hash:
|
|
72
73
|
wrong_element_type: "[%{service_class_name}] Wrong type in internal attribute hash `%{internal_name}`, expected `%{expected_type}` for `%{key_name}`, got `%{given_type}`"
|
|
73
74
|
outputs:
|
|
74
75
|
undefined:
|
|
75
|
-
getter: "[%{service_class_name}] Undefined
|
|
76
|
-
setter: "[%{service_class_name}] Undefined
|
|
76
|
+
getter: "[%{service_class_name}] Undefined deserialization attribute `%{output_name}`"
|
|
77
|
+
setter: "[%{service_class_name}] Undefined deserialization attribute `%{output_name}`"
|
|
77
78
|
validations:
|
|
78
79
|
inclusion:
|
|
79
80
|
default_error: "[%{service_class_name}] Wrong value in `%{output_name}`, must be one of `%{output_inclusion}`"
|
|
80
81
|
must:
|
|
81
|
-
default_error: "[%{service_class_name}]
|
|
82
|
-
syntax_error: "[%{service_class_name}] Syntax error inside `%{code}` of `%{output_name}`
|
|
82
|
+
default_error: "[%{service_class_name}] Deserialization attribute `%{output_name}` must \"%{code}\""
|
|
83
|
+
syntax_error: "[%{service_class_name}] Syntax error inside `%{code}` of `%{output_name}` deserialization attribute: %{exception_message}"
|
|
83
84
|
dynamic_options:
|
|
85
|
+
consists_of:
|
|
86
|
+
required: "[%{service_class_name}] Required element in deserialization attribute collection `%{output_name}` is missing"
|
|
87
|
+
wrong_type: "[%{service_class_name}] Wrong deserialization attribute collection type `%{output_name}`, expected `%{expected_type}`, got `%{given_type}`"
|
|
88
|
+
wrong_element_type: "[%{service_class_name}] Wrong element type in deserialization attribute collection `%{output_name}`, expected `%{expected_type}`, got `%{given_type}`"
|
|
84
89
|
format:
|
|
85
|
-
default: "[%{service_class_name}]
|
|
86
|
-
wrong_pattern: "[%{service_class_name}]
|
|
87
|
-
unknown: "[%{service_class_name}] Unknown `%{format_name}` format specified for
|
|
90
|
+
default: "[%{service_class_name}] Deserialization attribute `%{output_name}` does not match `%{format_name}` format"
|
|
91
|
+
wrong_pattern: "[%{service_class_name}] Deserialization attribute `%{output_name}` does not match `%{format_name}` format"
|
|
92
|
+
unknown: "[%{service_class_name}] Unknown `%{format_name}` format specified for deserialization attribute `%{output_name}`"
|
|
88
93
|
min:
|
|
89
|
-
default: "[%{service_class_name}]
|
|
94
|
+
default: "[%{service_class_name}] Deserialization attribute `%{output_name}` received value `%{value}`, which is less than `%{option_value}`"
|
|
90
95
|
max:
|
|
91
|
-
default: "[%{service_class_name}]
|
|
96
|
+
default: "[%{service_class_name}] Deserialization attribute `%{output_name}` received value `%{value}`, which is greater than `%{option_value}`"
|
|
92
97
|
type:
|
|
93
98
|
default_error:
|
|
94
|
-
default: "[%{service_class_name}] Wrong type of
|
|
95
|
-
for_collection:
|
|
96
|
-
wrong_type: "[%{service_class_name}] Wrong output attribute collection type `%{output_name}`, expected `%{expected_type}`, got `%{given_type}`"
|
|
97
|
-
wrong_element_type: "[%{service_class_name}] Wrong element type in output attribute collection `%{output_name}`, expected `%{expected_type}`, got `%{given_type}`"
|
|
99
|
+
default: "[%{service_class_name}] Wrong type of deserialization attribute `%{output_name}`, expected `%{expected_type}`, got `%{given_type}`"
|
|
98
100
|
for_hash:
|
|
99
|
-
wrong_element_type: "[%{service_class_name}] Wrong type in
|
|
101
|
+
wrong_element_type: "[%{service_class_name}] Wrong type in deserialization attribute hash `%{output_name}`, expected `%{expected_type}` for `%{key_name}`, got `%{given_type}`"
|
data/config/locales/ru.yml
CHANGED
|
@@ -9,41 +9,40 @@ ru:
|
|
|
9
9
|
cannot_be_overwritten: "[%{service_class_name}] Нельзя перезаписать следующие методы: %{list_of_methods}"
|
|
10
10
|
inputs:
|
|
11
11
|
undefined:
|
|
12
|
-
getter: "[%{service_class_name}] Неизвестный входящий атрибут `%{input_name}`"
|
|
13
|
-
setter: "[%{service_class_name}] Неизвестный входящий атрибут `%{input_name}`"
|
|
12
|
+
getter: "[%{service_class_name}] Неизвестный входящий атрибут сериализации `%{input_name}`"
|
|
13
|
+
setter: "[%{service_class_name}] Неизвестный входящий атрибут сериализации `%{input_name}`"
|
|
14
14
|
validations:
|
|
15
15
|
inclusion:
|
|
16
16
|
default_error: "[%{service_class_name}] Неправильное значение в `%{input_name}`, должно быть одним из `%{input_inclusion}`"
|
|
17
17
|
must:
|
|
18
|
-
default_error: "[%{service_class_name}]
|
|
19
|
-
syntax_error: "[%{service_class_name}] Синтаксическая ошибка внутри `%{code}`
|
|
18
|
+
default_error: "[%{service_class_name}] Атрибут сериализации `%{input_name}` должен \"%{code}\""
|
|
19
|
+
syntax_error: "[%{service_class_name}] Синтаксическая ошибка внутри `%{code}` атрибута сериализации `%{input_name}`: %{exception_message}"
|
|
20
20
|
dynamic_options:
|
|
21
|
+
consists_of:
|
|
22
|
+
required: "[%{service_class_name}] Отсутствует обязательный элемент в коллекции атрибута сериализации `%{input_name}`"
|
|
23
|
+
wrong_type: "[%{service_class_name}] Неправильный тип коллекции атрибута сериализации `%{input_name}`, ожидалось `%{expected_type}`, получено `%{given_type}`"
|
|
24
|
+
wrong_element_type: "[%{service_class_name}] Неправильный тип элемента в коллекции атрибута сериализации `%{input_name}`, ожидалось `%{expected_type}`, получено `%{given_type}`"
|
|
21
25
|
format:
|
|
22
|
-
default: "[%{service_class_name}]
|
|
23
|
-
wrong_pattern: "[%{service_class_name}]
|
|
24
|
-
unknown: "[%{service_class_name}] Указан неизвестный формат `%{format_name}` у
|
|
26
|
+
default: "[%{service_class_name}] Атрибут сериализации `%{input_name}` не соответствует формату `%{format_name}`"
|
|
27
|
+
wrong_pattern: "[%{service_class_name}] Атрибут сериализации `%{input_name}` не соответствует формату `%{format_name}`"
|
|
28
|
+
unknown: "[%{service_class_name}] Указан неизвестный формат `%{format_name}` у атрибута сериализации `%{input_name}`"
|
|
25
29
|
min:
|
|
26
|
-
default: "[%{service_class_name}]
|
|
30
|
+
default: "[%{service_class_name}] Атрибут сериализации `%{input_name}` получил значение `%{value}`, которое меньше `%{option_value}`"
|
|
27
31
|
max:
|
|
28
|
-
default: "[%{service_class_name}]
|
|
32
|
+
default: "[%{service_class_name}] Атрибут сериализации `%{input_name}` получил значение `%{value}`, которое больше `%{option_value}`"
|
|
29
33
|
required:
|
|
30
34
|
default_error:
|
|
31
|
-
default: "[%{service_class_name}] Обязательный
|
|
32
|
-
for_collection: "[%{service_class_name}] Обязательный элемент в коллекции инпута `%{input_name}` отсутствует"
|
|
35
|
+
default: "[%{service_class_name}] Обязательный атрибут сериализации `%{input_name}` отсутствует"
|
|
33
36
|
type:
|
|
34
37
|
default_error:
|
|
35
|
-
default: "[%{service_class_name}] Неправильный тип
|
|
36
|
-
for_collection:
|
|
37
|
-
wrong_type: "[%{service_class_name}] Неправильный тип коллекции инпута `%{input_name}`, ожидалось `%{expected_type}`, получено `%{given_type}`"
|
|
38
|
-
wrong_element_type: "[%{service_class_name}] Неправильный тип в коллекции инпута `%{input_name}`, ожидалось `%{expected_type}`, получено `%{given_type}`"
|
|
38
|
+
default: "[%{service_class_name}] Неправильный тип атрибута сериализации `%{input_name}`, ожидалось `%{expected_type}`, получено `%{given_type}`"
|
|
39
39
|
for_hash:
|
|
40
|
-
wrong_element_type: "[%{service_class_name}] Неправильный тип в хеше
|
|
41
|
-
|
|
40
|
+
wrong_element_type: "[%{service_class_name}] Неправильный тип в хеше атрибута сериализации `%{input_name}`, для `%{key_name}` ожидалось `%{expected_type}`, получено `%{given_type}`"
|
|
42
41
|
tools:
|
|
43
42
|
find_unnecessary:
|
|
44
43
|
error: "[%{service_class_name}] Неожиданные атрибуты: `%{unnecessary_attributes}`"
|
|
45
44
|
rules:
|
|
46
|
-
error: "[%{service_class_name}] Конфликт в опциях
|
|
45
|
+
error: "[%{service_class_name}] Конфликт в опциях атрибута сериализации `%{input_name}`: `%{conflict_code}`"
|
|
47
46
|
internals:
|
|
48
47
|
undefined:
|
|
49
48
|
getter: "[%{service_class_name}] Неизвестный внутренний атрибут `%{internal_name}`"
|
|
@@ -55,6 +54,10 @@ ru:
|
|
|
55
54
|
default_error: "[%{service_class_name}] Внутренний атрибут `%{internal_name}` должен \"%{code}\""
|
|
56
55
|
syntax_error: "[%{service_class_name}] Синтаксическая ошибка внутри `%{code}` внутреннего атрибута `%{internal_name}`: %{exception_message}"
|
|
57
56
|
dynamic_options:
|
|
57
|
+
consists_of:
|
|
58
|
+
required: "[%{service_class_name}] Отсутствует обязательный элемент в коллекции внутреннего атрибута `%{internal_name}`"
|
|
59
|
+
wrong_type: "[%{service_class_name}] Неправильный тип коллекции внутреннего атрибута `%{internal_name}`, ожидалось `%{expected_type}`, получено `%{given_type}`"
|
|
60
|
+
wrong_element_type: "[%{service_class_name}] Неправильный тип элемента в коллекции внутреннего атрибута `%{internal_name}`, ожидалось `%{expected_type}`, получено `%{given_type}`"
|
|
58
61
|
format:
|
|
59
62
|
default: "[%{service_class_name}] Внутренний атрибут `%{internal_name}` не соответствует формату `%{format_name}`"
|
|
60
63
|
wrong_pattern: "[%{service_class_name}] Внутренний атрибут `%{internal_name}` не соответствует формату `%{format_name}`"
|
|
@@ -66,34 +69,33 @@ ru:
|
|
|
66
69
|
type:
|
|
67
70
|
default_error:
|
|
68
71
|
default: "[%{service_class_name}] Неправильный тип внутреннего атрибута `%{internal_name}`, ожидалось `%{expected_type}`, получено `%{given_type}`"
|
|
69
|
-
for_collection:
|
|
70
|
-
wrong_type: "[%{service_class_name}] Неправильный тип коллекции внутреннего атрибута `%{internal_name}`, ожидалось `%{expected_type}`, получено `%{given_type}`"
|
|
71
|
-
wrong_element_type: "[%{service_class_name}] Неправильный тип элемента в коллекции внутреннего атрибута `%{internal_name}`, ожидалось `%{expected_type}`, получено `%{given_type}`"
|
|
72
72
|
for_hash:
|
|
73
73
|
wrong_element_type: "[%{service_class_name}] Неправильный тип в хеше внутреннего атрибута `%{internal_name}`, для `%{key_name}` ожидалось `%{expected_type}`, получено `%{given_type}`"
|
|
74
74
|
outputs:
|
|
75
75
|
undefined:
|
|
76
|
-
getter: "[%{service_class_name}] Неизвестный
|
|
77
|
-
setter: "[%{service_class_name}] Неизвестный
|
|
76
|
+
getter: "[%{service_class_name}] Неизвестный атрибут десериализации `%{output_name}`"
|
|
77
|
+
setter: "[%{service_class_name}] Неизвестный атрибут десериализации `%{output_name}`"
|
|
78
78
|
validations:
|
|
79
79
|
inclusion:
|
|
80
80
|
default_error: "[%{service_class_name}] Неправильное значение в `%{output_name}`, должно быть одним из `%{output_inclusion}`"
|
|
81
81
|
must:
|
|
82
|
-
default_error: "[%{service_class_name}]
|
|
83
|
-
syntax_error: "[%{service_class_name}] Синтаксическая ошибка внутри `%{code}`
|
|
82
|
+
default_error: "[%{service_class_name}] Атрибут десериализации `%{output_name}` должен \"%{code}\""
|
|
83
|
+
syntax_error: "[%{service_class_name}] Синтаксическая ошибка внутри `%{code}` атрибута десериализации `%{output_name}`: %{exception_message}"
|
|
84
84
|
dynamic_options:
|
|
85
|
+
consists_of:
|
|
86
|
+
required: "[%{service_class_name}] Отсутствует обязательный элемент в коллекции атрибута десериализации `%{output_name}`"
|
|
87
|
+
wrong_type: "[%{service_class_name}] Неправильный тип коллекции атрибута десериализации `%{output_name}`, ожидалось `%{expected_type}`, получено `%{given_type}`"
|
|
88
|
+
wrong_element_type: "[%{service_class_name}] Неправильный тип элемента в коллекции атрибута десериализации `%{output_name}`, ожидалось `%{expected_type}`, получено `%{given_type}`"
|
|
85
89
|
format:
|
|
86
|
-
default: "[%{service_class_name}]
|
|
87
|
-
wrong_pattern: "[%{service_class_name}]
|
|
88
|
-
unknown: "[%{service_class_name}] Указан неизвестный формат `%{format_name}` у
|
|
90
|
+
default: "[%{service_class_name}] Атрибут десериализации `%{output_name}` не соответствует формату `%{format_name}`"
|
|
91
|
+
wrong_pattern: "[%{service_class_name}] Атрибут десериализации `%{output_name}` не соответствует формату `%{format_name}`"
|
|
92
|
+
unknown: "[%{service_class_name}] Указан неизвестный формат `%{format_name}` у атрибута десериализации `%{output_name}`"
|
|
89
93
|
min:
|
|
90
|
-
default: "[%{service_class_name}]
|
|
94
|
+
default: "[%{service_class_name}] Атрибут десериализации `%{output_name}` получил значение `%{value}`, которое меньше `%{option_value}`"
|
|
91
95
|
max:
|
|
92
|
-
default: "[%{service_class_name}]
|
|
96
|
+
default: "[%{service_class_name}] Атрибут десериализации `%{output_name}` получил значение `%{value}`, которое больше `%{option_value}`"
|
|
93
97
|
type:
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
for_hash:
|
|
99
|
-
wrong_element_type: "[%{service_class_name}] Неправильный тип в хеше выходящего атрибута `%{output_name}`, для `%{key_name}` ожидалось `%{expected_type}`, получено `%{given_type}`"
|
|
98
|
+
default_error:
|
|
99
|
+
default: "[%{service_class_name}] Неправильный тип атрибута десериализации `%{output_name}`, ожидалось `%{expected_type}`, получено `%{given_type}`"
|
|
100
|
+
for_hash:
|
|
101
|
+
wrong_element_type: "[%{service_class_name}] Неправильный тип в хеше атрибута десериализации `%{output_name}`, для `%{key_name}` ожидалось `%{expected_type}`, получено `%{given_type}`"
|
|
@@ -5,7 +5,7 @@ module Datory
|
|
|
5
5
|
class Attribute
|
|
6
6
|
attr_reader :from, :to
|
|
7
7
|
|
|
8
|
-
def initialize(name, **options) # rubocop:disable Metrics/MethodLength
|
|
8
|
+
def initialize(name, **options) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
|
9
9
|
@from = Options::From.new(
|
|
10
10
|
name: name,
|
|
11
11
|
type: options.fetch(:from),
|
|
@@ -20,6 +20,7 @@ module Datory
|
|
|
20
20
|
type: options.fetch(:as, @from.type),
|
|
21
21
|
# TODO: It is necessary to implement NilClass support for optional
|
|
22
22
|
required: options.fetch(:required, true),
|
|
23
|
+
default: options.fetch(:default, nil),
|
|
23
24
|
consists_of: @from.consists_of,
|
|
24
25
|
min: @from.min,
|
|
25
26
|
max: @from.max,
|
|
@@ -30,11 +31,12 @@ module Datory
|
|
|
30
31
|
|
|
31
32
|
##########################################################################
|
|
32
33
|
|
|
33
|
-
def input_serialization_options # rubocop:disable Metrics/AbcSize
|
|
34
|
+
def input_serialization_options # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
|
34
35
|
hash = {
|
|
35
36
|
as: to.name,
|
|
36
37
|
type: to.type,
|
|
37
38
|
required: to.required,
|
|
39
|
+
default: to.default,
|
|
38
40
|
consists_of: to.consists_of
|
|
39
41
|
}
|
|
40
42
|
|
|
@@ -64,11 +66,12 @@ module Datory
|
|
|
64
66
|
|
|
65
67
|
##########################################################################
|
|
66
68
|
|
|
67
|
-
def input_deserialization_options # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
|
69
|
+
def input_deserialization_options # rubocop:disable Metrics/MethodLength, Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
|
68
70
|
hash = {
|
|
69
71
|
as: to.name,
|
|
70
72
|
type: from.type,
|
|
71
73
|
required: to.required,
|
|
74
|
+
default: to.default,
|
|
72
75
|
consists_of: from.consists_of,
|
|
73
76
|
prepare: (lambda do |value:|
|
|
74
77
|
return value unless to.include_class.present?
|
|
@@ -76,6 +79,8 @@ module Datory
|
|
|
76
79
|
if [Set, Array].include?(from.type)
|
|
77
80
|
value.map { |item| to.include_class.deserialize(**item) }
|
|
78
81
|
else
|
|
82
|
+
return nil if value.nil? # NOTE: When `one` is optional and not passed
|
|
83
|
+
|
|
79
84
|
to.include_class.deserialize(**value)
|
|
80
85
|
end
|
|
81
86
|
end)
|
|
@@ -8,7 +8,7 @@ module Datory
|
|
|
8
8
|
base.include(Workspace)
|
|
9
9
|
end
|
|
10
10
|
|
|
11
|
-
module ClassMethods
|
|
11
|
+
module ClassMethods # rubocop:disable Metrics/ModuleLength
|
|
12
12
|
def inherited(child)
|
|
13
13
|
super
|
|
14
14
|
|
|
@@ -23,7 +23,7 @@ module Datory
|
|
|
23
23
|
|
|
24
24
|
########################################################################
|
|
25
25
|
|
|
26
|
-
def one(name, include:, to: nil)
|
|
26
|
+
def one!(name, include:, to: nil)
|
|
27
27
|
attribute(
|
|
28
28
|
name,
|
|
29
29
|
to: to.presence || name,
|
|
@@ -32,8 +32,21 @@ module Datory
|
|
|
32
32
|
as: [Datory::Result, Hash]
|
|
33
33
|
)
|
|
34
34
|
end
|
|
35
|
+
# NOTE: This will most likely be marked as deprecated in the future in favor of `one!`
|
|
36
|
+
alias one one!
|
|
35
37
|
|
|
36
|
-
def
|
|
38
|
+
def one?(name, include:, to: nil)
|
|
39
|
+
attribute(
|
|
40
|
+
name,
|
|
41
|
+
to: to.presence || name,
|
|
42
|
+
from: [Hash, NilClass],
|
|
43
|
+
include: include,
|
|
44
|
+
as: [Datory::Result, Hash, NilClass],
|
|
45
|
+
required: false
|
|
46
|
+
)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def many!(name, include:, to: nil)
|
|
37
50
|
attribute(
|
|
38
51
|
name,
|
|
39
52
|
to: to.presence || name,
|
|
@@ -43,67 +56,174 @@ module Datory
|
|
|
43
56
|
as: Array
|
|
44
57
|
)
|
|
45
58
|
end
|
|
59
|
+
# NOTE: This will most likely be marked as deprecated in the future in favor of `many!`
|
|
60
|
+
alias many many!
|
|
61
|
+
|
|
62
|
+
def many?(name, include:, to: nil)
|
|
63
|
+
attribute(
|
|
64
|
+
name,
|
|
65
|
+
to: to.presence || name,
|
|
66
|
+
from: Array,
|
|
67
|
+
consists_of: [Datory::Result, Hash],
|
|
68
|
+
include: include,
|
|
69
|
+
as: Array,
|
|
70
|
+
required: false,
|
|
71
|
+
default: []
|
|
72
|
+
)
|
|
73
|
+
end
|
|
46
74
|
|
|
47
75
|
########################################################################
|
|
48
76
|
|
|
49
|
-
def uuid(name, **options)
|
|
77
|
+
def uuid!(name, **options)
|
|
50
78
|
options = options.slice(:to)
|
|
51
79
|
options = options.merge(format: :uuid)
|
|
52
|
-
string(name, **options)
|
|
80
|
+
string!(name, **options)
|
|
81
|
+
end
|
|
82
|
+
# NOTE: This will most likely be marked as deprecated in the future in favor of `uuid!`
|
|
83
|
+
alias uuid uuid!
|
|
84
|
+
|
|
85
|
+
def uuid?(name, **options)
|
|
86
|
+
options = options.slice(:to)
|
|
87
|
+
options = options.merge(format: :uuid)
|
|
88
|
+
string?(name, **options)
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def money!(name, **options)
|
|
92
|
+
options = options.slice(:to)
|
|
93
|
+
|
|
94
|
+
integer! :"#{name}_cents", **options
|
|
95
|
+
string! :"#{name}_currency", **options
|
|
53
96
|
end
|
|
97
|
+
# NOTE: This will most likely be marked as deprecated in the future in favor of `money!`
|
|
98
|
+
alias money money!
|
|
54
99
|
|
|
55
|
-
def money(name, **options)
|
|
100
|
+
def money?(name, **options)
|
|
56
101
|
options = options.slice(:to)
|
|
57
102
|
|
|
58
|
-
integer :"#{name}_cents", **options
|
|
59
|
-
string :"#{name}_currency", **options
|
|
103
|
+
integer? :"#{name}_cents", **options
|
|
104
|
+
string? :"#{name}_currency", **options
|
|
60
105
|
end
|
|
61
106
|
|
|
62
|
-
def duration(name, **options)
|
|
107
|
+
def duration!(name, **options)
|
|
63
108
|
options = options.slice(:to)
|
|
64
109
|
options = options.merge(from: String, as: ActiveSupport::Duration, format: { from: :duration })
|
|
65
|
-
|
|
110
|
+
attribute(name, **options)
|
|
66
111
|
end
|
|
112
|
+
# NOTE: This will most likely be marked as deprecated in the future in favor of `duration!`
|
|
113
|
+
alias duration duration!
|
|
67
114
|
|
|
68
|
-
def
|
|
115
|
+
def duration?(name, **options)
|
|
116
|
+
options = options.slice(:to)
|
|
117
|
+
options = options.merge(
|
|
118
|
+
from: [String, NilClass],
|
|
119
|
+
as: [ActiveSupport::Duration, NilClass],
|
|
120
|
+
format: { from: :duration },
|
|
121
|
+
required: false
|
|
122
|
+
)
|
|
123
|
+
attribute(name, **options)
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
def date!(name, **options)
|
|
69
127
|
options = options.slice(:to)
|
|
70
128
|
options = options.merge(from: String, as: Date, format: { from: :date })
|
|
71
|
-
|
|
129
|
+
attribute(name, **options)
|
|
130
|
+
end
|
|
131
|
+
# NOTE: This will most likely be marked as deprecated in the future in favor of `date!`
|
|
132
|
+
alias date date!
|
|
133
|
+
|
|
134
|
+
def date?(name, **options)
|
|
135
|
+
options = options.slice(:to)
|
|
136
|
+
options = options.merge(
|
|
137
|
+
from: [String, NilClass],
|
|
138
|
+
as: [Date, NilClass],
|
|
139
|
+
format: { from: :date },
|
|
140
|
+
required: false
|
|
141
|
+
)
|
|
142
|
+
attribute(name, **options)
|
|
72
143
|
end
|
|
73
144
|
|
|
74
|
-
def time(name, **options)
|
|
145
|
+
def time!(name, **options)
|
|
75
146
|
options = options.slice(:to)
|
|
76
147
|
options = options.merge(from: String, as: Time, format: { from: :time })
|
|
77
|
-
|
|
148
|
+
attribute(name, **options)
|
|
78
149
|
end
|
|
150
|
+
# NOTE: This will most likely be marked as deprecated in the future in favor of `time!`
|
|
151
|
+
alias time time!
|
|
79
152
|
|
|
80
|
-
def
|
|
153
|
+
def time?(name, **options)
|
|
154
|
+
options = options.slice(:to)
|
|
155
|
+
options = options.merge(
|
|
156
|
+
from: [String, NilClass],
|
|
157
|
+
as: [Time, NilClass],
|
|
158
|
+
format: { from: :time },
|
|
159
|
+
required: false
|
|
160
|
+
)
|
|
161
|
+
attribute(name, **options)
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
def datetime!(name, **options)
|
|
81
165
|
options = options.slice(:to)
|
|
82
166
|
options = options.merge(from: String, as: DateTime, format: { from: :datetime })
|
|
83
|
-
|
|
167
|
+
attribute(name, **options)
|
|
168
|
+
end
|
|
169
|
+
# NOTE: This will most likely be marked as deprecated in the future in favor of `datetime!`
|
|
170
|
+
alias datetime datetime!
|
|
171
|
+
|
|
172
|
+
def datetime?(name, **options)
|
|
173
|
+
options = options.slice(:to)
|
|
174
|
+
options = options.merge(
|
|
175
|
+
from: [String, NilClass],
|
|
176
|
+
as: [DateTime, NilClass],
|
|
177
|
+
format: { from: :datetime },
|
|
178
|
+
required: false
|
|
179
|
+
)
|
|
180
|
+
attribute(name, **options)
|
|
84
181
|
end
|
|
85
182
|
|
|
86
183
|
########################################################################
|
|
87
184
|
|
|
88
|
-
def string(name, **options)
|
|
185
|
+
def string!(name, **options)
|
|
89
186
|
options = options.merge(from: String)
|
|
90
187
|
attribute(name, **options)
|
|
91
188
|
end
|
|
189
|
+
# NOTE: This will most likely be marked as deprecated in the future in favor of `string!`
|
|
190
|
+
alias string string!
|
|
191
|
+
|
|
192
|
+
def string?(name, **options)
|
|
193
|
+
options = options.merge(from: [String, NilClass], as: [String, NilClass], required: false)
|
|
194
|
+
attribute(name, **options)
|
|
195
|
+
end
|
|
92
196
|
|
|
93
|
-
def integer(name, **options)
|
|
197
|
+
def integer!(name, **options)
|
|
94
198
|
options = options.merge(from: Integer)
|
|
95
199
|
attribute(name, **options)
|
|
96
200
|
end
|
|
201
|
+
# NOTE: This will most likely be marked as deprecated in the future in favor of `integer!`
|
|
202
|
+
alias integer integer!
|
|
203
|
+
|
|
204
|
+
def integer?(name, **options)
|
|
205
|
+
options = options.merge(from: [Integer, NilClass], as: [Integer, NilClass], required: false)
|
|
206
|
+
attribute(name, **options)
|
|
207
|
+
end
|
|
97
208
|
|
|
98
|
-
def float(name, **options)
|
|
209
|
+
def float!(name, **options)
|
|
99
210
|
options = options.merge(from: Float)
|
|
100
211
|
attribute(name, **options)
|
|
101
212
|
end
|
|
213
|
+
# NOTE: This will most likely be marked as deprecated in the future in favor of `float!`
|
|
214
|
+
alias float float!
|
|
215
|
+
|
|
216
|
+
def float?(name, **options)
|
|
217
|
+
options = options.merge(from: [Float, NilClass], as: [Float, NilClass], required: false)
|
|
218
|
+
attribute(name, **options)
|
|
219
|
+
end
|
|
102
220
|
|
|
103
|
-
def boolean(name, **options)
|
|
221
|
+
def boolean!(name, **options)
|
|
104
222
|
options = options.merge(from: [TrueClass, FalseClass])
|
|
105
223
|
attribute(name, **options)
|
|
106
224
|
end
|
|
225
|
+
# NOTE: This will most likely be marked as deprecated in the future in favor of `boolean!`
|
|
226
|
+
alias boolean boolean!
|
|
107
227
|
|
|
108
228
|
########################################################################
|
|
109
229
|
|
|
@@ -4,10 +4,11 @@ module Datory
|
|
|
4
4
|
module Attributes
|
|
5
5
|
module Options
|
|
6
6
|
class To < Base
|
|
7
|
-
attr_reader :required, :include_class
|
|
7
|
+
attr_reader :required, :default, :include_class
|
|
8
8
|
|
|
9
|
-
def initialize(name:, type:, required:, consists_of:, min:, max:, format:, include_class:)
|
|
9
|
+
def initialize(name:, type:, required:, default:, consists_of:, min:, max:, format:, include_class:)
|
|
10
10
|
@required = required
|
|
11
|
+
@default = default
|
|
11
12
|
@include_class = include_class
|
|
12
13
|
|
|
13
14
|
format = format.fetch(:to, nil) if format.is_a?(Hash)
|
|
@@ -18,6 +19,7 @@ module Datory
|
|
|
18
19
|
def info
|
|
19
20
|
super.merge(
|
|
20
21
|
required: required,
|
|
22
|
+
default: default,
|
|
21
23
|
include: include_class
|
|
22
24
|
)
|
|
23
25
|
end
|
|
@@ -8,6 +8,8 @@ module Datory
|
|
|
8
8
|
def serialize(model:, collection_of_attributes:)
|
|
9
9
|
super
|
|
10
10
|
|
|
11
|
+
return nil if model.nil? # NOTE: When `one` is optional and not passed
|
|
12
|
+
|
|
11
13
|
model = Serialization::ServiceBuilder.build!(self, model, collection_of_attributes)
|
|
12
14
|
|
|
13
15
|
Serialization::Serializator.serialize(
|
|
@@ -15,10 +15,12 @@ module Datory
|
|
|
15
15
|
ActiveSupport::Duration => ->(value) { value.iso8601 }
|
|
16
16
|
},
|
|
17
17
|
DESERIALIZATION: {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
# NOTE: These types do not need to be cast automatically:
|
|
19
|
+
# Symbol => ->(value) { value.to_sym },
|
|
20
|
+
# String => ->(value) { value.to_s },
|
|
21
|
+
# Integer => ->(value) { value.to_i },
|
|
22
|
+
# Float => ->(value) { value.to_f },
|
|
23
|
+
# NOTE: These types need to be cast automatically:
|
|
22
24
|
Date => ->(value) { Date.parse(value) },
|
|
23
25
|
Time => ->(value) { Time.parse(value) },
|
|
24
26
|
DateTime => ->(value) { DateTime.parse(value) },
|
|
@@ -62,7 +64,14 @@ module Datory
|
|
|
62
64
|
define_method(method_name) do
|
|
63
65
|
value = inputs.public_send(deserialized_name)
|
|
64
66
|
|
|
65
|
-
value
|
|
67
|
+
if value.present?
|
|
68
|
+
type = attribute.to.type
|
|
69
|
+
|
|
70
|
+
# NOTE: For optional attributes.
|
|
71
|
+
type = (type - [NilClass]).first if type.is_a?(Array)
|
|
72
|
+
|
|
73
|
+
value = TRANSFORMATIONS.fetch(:DESERIALIZATION).fetch(type, ->(v) { v }).call(value)
|
|
74
|
+
end
|
|
66
75
|
|
|
67
76
|
outputs.public_send(:"#{deserialized_name}=", value)
|
|
68
77
|
end
|
data/lib/datory/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: datory
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.0.
|
|
4
|
+
version: 1.0.0.rc23
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Anton Sokolov
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2024-
|
|
11
|
+
date: 2024-06-06 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activesupport
|