reject_deeply_nested 0.1.0 → 0.2.0

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
  SHA1:
3
- metadata.gz: d01bd2768aa511a29a9cfc5cce5f1e002f50c842
4
- data.tar.gz: 42c794be33de29867e0d7c6808a048649377f803
3
+ metadata.gz: ed0d7fc7795202ddd6505bc0d2a67db8b367dfe6
4
+ data.tar.gz: 1ca972ff3d6cf51686d0671c1dd0a3f7311d7faf
5
5
  SHA512:
6
- metadata.gz: 337fe5763755d7cb54c00946a4ee236cdc3519d06a23f70615c1c0cfd5487053b0b399f481d33fd7f57507d43dbecb3c692a75672a952c62d2be83d6f0db2571
7
- data.tar.gz: 542b71f578332fcc90a7bde597a56333e468ef854b3594e1f2c26c9e59e14e12e7cbaa7ba4cd9a39f3403b0641f320a7d2f3c330a97f73eef85c7eeaad3db6bb
6
+ metadata.gz: c0b458719d2f43d45073bfae14f99eb0e1d12e6c099788ca6c3fec172deb71799b77985096f272fa0c9ad42c2a708a1fbaa9a63461f5a83be5fa297a0b9ef079
7
+ data.tar.gz: c8d90c01d6da054afa1a3031a90e909f58a5738431b0e1122902298cd623c3f4c7e7b4b6d9c8d2fe454a7ed9ef60b710cbc901df4df7ccb1d7f3499e4307cd72
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # RejectDeeplyNested
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/reject_deeply_nested.svg)](https://badge.fury.io/rb/reject_deeply_nested) [![Build Status](https://travis-ci.org/ignat-zakrevsky/reject_deeply_nested.svg?branch=master)](https://travis-ci.org/ignat-zakrevsky/reject_deeply_nested)
4
+
3
5
  Gem for rejecting deeply nested structures when you are using `accept_nested_attributes_for`. Using recursive traverse instead of stack because of [this](<https://gist.github.com/ignat-zakrevsky/6779db323c64faf4ed89>).
4
6
 
5
7
  ## Installation
@@ -25,13 +27,21 @@ There are two cases of using `reject_deeply_nested`
25
27
  When you simply want to reject nested blank values:
26
28
 
27
29
  ```ruby
28
- accepts_nested_attributes_for :dependents, reject_if: RejectDeeplyNested::BLANK
30
+ accepts_nested_attributes_for :dependents,
31
+ reject_if: RejectDeeplyNested::BLANK
29
32
  ```
30
33
 
31
34
  Other case, when you want to ignore some additional fields, for example id's keys
32
35
 
33
36
  ```ruby
34
- accepts_nested_attributes_for :dependents, reject_if: RejectDeeplyNested::SMART_BLANK.curry.([/_id$/])
37
+ accepts_nested_attributes_for :dependents,
38
+ reject_if: RejectDeeplyNested::SMART_BLANK.curry.([/_id$/])
39
+ ```
40
+
41
+ Additionaly, if you want to reject not complete filled attributes you can use
42
+ ```ruby
43
+ accepts_nested_attributes_for :dependents,
44
+ reject_if: RejectDeeplyNested::ANY_MISSED.curry.(['name', 'age'])
35
45
  ```
36
46
 
37
47
  P.S. I'm not sure about convenient format for such methods.
data/Rakefile CHANGED
@@ -7,4 +7,4 @@ Rake::TestTask.new(:test) do |t|
7
7
  t.test_files = FileList['test/**/*_test.rb']
8
8
  end
9
9
 
10
- task :default => :spec
10
+ task :default => :test
@@ -1,3 +1,3 @@
1
1
  module RejectDeeplyNested
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -8,6 +8,9 @@ module RejectDeeplyNested
8
8
  SMART_BLANK = proc do |ignore_values, attributes|
9
9
  deep_blank?(attributes, Array(ignore_values) + DEFAULT_IGNORE_VALUES)
10
10
  end
11
+ ANY_MISSED = proc do |fields, attributes|
12
+ fields.any? { |field| attributes[field].blank? }
13
+ end
11
14
 
12
15
  private
13
16
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reject_deeply_nested
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ignat Zakrevsky
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-01-23 00:00:00.000000000 Z
11
+ date: 2016-02-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport