has_embedded_document 0.1.0 → 0.1.1
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/Gemfile.lock +1 -1
- data/lib/has_embedded_document/dsl.rb +6 -6
- data/lib/has_embedded_document/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 114ae2076fb500aa0099ea103a440ba07a84efc3e0ef90de5572d1b756ccd565
|
4
|
+
data.tar.gz: 799523e0275cdaef8338b9ed11eb16af00b72da98ae3c0a4acc98f477d7fac06
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 592b0e77e43de7f5ca0fc72d5bec77b32be6d0496c825a791f78a51161fc2d8c87ebc6fd4fa256d59f6039956bfc38c79093e9c4bce65e2ea55bf192e55bbde8
|
7
|
+
data.tar.gz: d12b01062644de557a1ce86155c8d931f5da3cb86fdf9c148fb500774925fe0a71a4664683af34b1099f39727397204fc7b0948ed9b8b1b813c11b7d31fa45d0
|
data/Gemfile.lock
CHANGED
@@ -12,7 +12,7 @@ module HasEmbeddedDocument
|
|
12
12
|
define_embedded_writer(name, document_class)
|
13
13
|
|
14
14
|
validates(name, presence: { message: :required }) unless optional
|
15
|
-
validate_embedded_document(name) if validate
|
15
|
+
validate_embedded_document(name, **(validate.is_a?(Hash) ? validate : {})) if validate
|
16
16
|
end
|
17
17
|
|
18
18
|
# @param name [Symbol]
|
@@ -25,13 +25,13 @@ module HasEmbeddedDocument
|
|
25
25
|
define_embedded_array_writer(name, document_class)
|
26
26
|
|
27
27
|
validates(name, presence: { message: :required }) unless optional
|
28
|
-
validate_many_embedded_documents(name) if validate
|
28
|
+
validate_many_embedded_documents(name, **(validate.is_a?(Hash) ? validate : {})) if validate
|
29
29
|
end
|
30
30
|
|
31
31
|
# @param name [Symbol]
|
32
32
|
# @return [void]
|
33
|
-
def validate_embedded_document(name)
|
34
|
-
validate do
|
33
|
+
def validate_embedded_document(name, **options)
|
34
|
+
validate(**options) do
|
35
35
|
document = send(name)
|
36
36
|
|
37
37
|
if document&.invalid?
|
@@ -44,8 +44,8 @@ module HasEmbeddedDocument
|
|
44
44
|
|
45
45
|
# @param name [Symbol]
|
46
46
|
# @return [void]
|
47
|
-
def validate_many_embedded_documents(name)
|
48
|
-
validate do
|
47
|
+
def validate_many_embedded_documents(name, **options)
|
48
|
+
validate(**options) do
|
49
49
|
documents = send(name)
|
50
50
|
|
51
51
|
documents&.each_with_index do |document, index|
|