has_embedded_document 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f6ef129f786a3baadf4af323f020e1383c5e32f98d71ad0e652b9f76dce86193
4
- data.tar.gz: f7bcdaea631373c214f13f074360d845eeae081dee58831d7e25694dfab67878
3
+ metadata.gz: 114ae2076fb500aa0099ea103a440ba07a84efc3e0ef90de5572d1b756ccd565
4
+ data.tar.gz: 799523e0275cdaef8338b9ed11eb16af00b72da98ae3c0a4acc98f477d7fac06
5
5
  SHA512:
6
- metadata.gz: 608a5f23ec84dcf6d0a653a237a34e98a632f05c30ed95c6e02ad4b3a38974faaee67239b56710daa397649aeaa55242cebf55685a5fea8c334be5f300ae6958
7
- data.tar.gz: 834235bff08e6f449a26919a714cd82f1e2ebdf866a2e3df68872ae1e71d2cc84684c77254f76c18aa050ae4e1da594bf6cbeb0795232980b7558d5e1534813d
6
+ metadata.gz: 592b0e77e43de7f5ca0fc72d5bec77b32be6d0496c825a791f78a51161fc2d8c87ebc6fd4fa256d59f6039956bfc38c79093e9c4bce65e2ea55bf192e55bbde8
7
+ data.tar.gz: d12b01062644de557a1ce86155c8d931f5da3cb86fdf9c148fb500774925fe0a71a4664683af34b1099f39727397204fc7b0948ed9b8b1b813c11b7d31fa45d0
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- has_embedded_document (0.1.0)
4
+ has_embedded_document (0.1.1)
5
5
  activerecord (>= 5.2.0)
6
6
 
7
7
  GEM
@@ -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|
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module HasEmbeddedDocument
4
- VERSION = '0.1.0'
4
+ VERSION = '0.1.1'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: has_embedded_document
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Minty Fresh