reject_deeply_nested 0.2.0 → 0.3.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ed0d7fc7795202ddd6505bc0d2a67db8b367dfe6
4
- data.tar.gz: 1ca972ff3d6cf51686d0671c1dd0a3f7311d7faf
3
+ metadata.gz: 560c01f2a2f57b8c994c0bc2240ce8ed8768216a
4
+ data.tar.gz: e85b5e2ce5e11f60d0cf35607b5b757949e9f749
5
5
  SHA512:
6
- metadata.gz: c0b458719d2f43d45073bfae14f99eb0e1d12e6c099788ca6c3fec172deb71799b77985096f272fa0c9ad42c2a708a1fbaa9a63461f5a83be5fa297a0b9ef079
7
- data.tar.gz: c8d90c01d6da054afa1a3031a90e909f58a5738431b0e1122902298cd623c3f4c7e7b4b6d9c8d2fe454a7ed9ef60b710cbc901df4df7ccb1d7f3499e4307cd72
6
+ metadata.gz: cf5751844916c4ea072122f9e689bdbde97a605558a8695c18f341462d8b7d59fb1baf470020afc9d4e4fc90e7cb0e1ce60db3e120b28d2350f415fe4d821433
7
+ data.tar.gz: d8cf7d62bd3861412d8cf53bdbf13ace6a06bbdc23941b1c440c9290aaae9a2fd1806aae39673b8160e08b0d6ea69370b090ffebb78c0a13d5f78d8c92ef8192
data/README.md CHANGED
@@ -28,24 +28,22 @@ When you simply want to reject nested blank values:
28
28
 
29
29
  ```ruby
30
30
  accepts_nested_attributes_for :dependents,
31
- reject_if: RejectDeeplyNested::BLANK
31
+ reject_if: RejectDeeplyNested.blank?
32
32
  ```
33
33
 
34
34
  Other case, when you want to ignore some additional fields, for example id's keys
35
35
 
36
36
  ```ruby
37
37
  accepts_nested_attributes_for :dependents,
38
- reject_if: RejectDeeplyNested::SMART_BLANK.curry.([/_id$/])
38
+ reject_if: RejectDeeplyNested.blank?([/_id$/])
39
39
  ```
40
40
 
41
41
  Additionaly, if you want to reject not complete filled attributes you can use
42
42
  ```ruby
43
43
  accepts_nested_attributes_for :dependents,
44
- reject_if: RejectDeeplyNested::ANY_MISSED.curry.(['name', 'age'])
44
+ reject_if: RejectDeeplyNested.any_missed?(['name', 'age'])
45
45
  ```
46
46
 
47
- P.S. I'm not sure about convenient format for such methods.
48
-
49
47
  ## Development
50
48
 
51
49
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -1,3 +1,3 @@
1
1
  module RejectDeeplyNested
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -12,6 +12,14 @@ module RejectDeeplyNested
12
12
  fields.any? { |field| attributes[field].blank? }
13
13
  end
14
14
 
15
+ def self.any_missed?(fields)
16
+ ANY_MISSED.curry.(fields)
17
+ end
18
+
19
+ def self.blank?(ignore_values = [])
20
+ SMART_BLANK.curry.(ignore_values)
21
+ end
22
+
15
23
  private
16
24
 
17
25
  # Recursively traverse nested attributes to define is all values blank.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reject_deeply_nested
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ignat Zakrevsky