normalizr 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +2 -2
- data/lib/normalizr/concern.rb +4 -2
- data/lib/normalizr/version.rb +1 -1
- data/spec/support/models/user.rb +3 -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: 03dfb54450a14ca113c1e45f01f0b7f14356e6f12f6cfa90dddb0d2f49f85635
|
4
|
+
data.tar.gz: d72f8210ab5e58c404efb64e6854de2f48a342f2388cd4ca5d3931fd07b59f47
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2627756373049880c2c048b738354282df325bcdf1e56d875cd702a8ecd5fc73b63fda8f300d0c2ce2738fc0777774e8a5f993a37bd598cfac5016fba76ae292
|
7
|
+
data.tar.gz: 2a9ec23470882aefb1c8a2b85aa2ba280ba1d490cea311eb4986a6f30382a9e73916b008b92aaed4c9ee5b5a8231b4a0a5c2f0bd251c7f9373330c714a885b4a
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -140,8 +140,8 @@ class Book
|
|
140
140
|
|
141
141
|
normalize :author, if: :author_should_be_normalized?
|
142
142
|
normalize :description, unless: :description_should_not_be_normalized?
|
143
|
-
|
144
|
-
normalize :author, if:
|
143
|
+
|
144
|
+
normalize :author, if: -> { date.today? }
|
145
145
|
end
|
146
146
|
```
|
147
147
|
|
data/lib/normalizr/concern.rb
CHANGED
@@ -11,8 +11,10 @@ module Normalizr
|
|
11
11
|
prepend Module.new {
|
12
12
|
options.attributes.each do |method|
|
13
13
|
define_method :"#{method}=" do |value|
|
14
|
-
|
15
|
-
|
14
|
+
condition_lambda = -> condition { Proc === condition ? instance_exec(&condition) : send(condition) }
|
15
|
+
|
16
|
+
positive = options.positive_condition.all? &condition_lambda
|
17
|
+
negative = options.negative_condition.none? &condition_lambda
|
16
18
|
|
17
19
|
if positive && negative
|
18
20
|
value = Normalizr.normalize(value, *options.before)
|
data/lib/normalizr/version.rb
CHANGED
data/spec/support/models/user.rb
CHANGED
@@ -3,7 +3,9 @@ class User < Person
|
|
3
3
|
|
4
4
|
normalize :lastname, if: :should_normalize_lastname?
|
5
5
|
normalize :maidenname, if: :should_normalize_maidenname_positive?, unless: :should_normalize_maidenname_negative?
|
6
|
-
normalize :favouritebook, if:
|
6
|
+
normalize :favouritebook, if: -> { true }
|
7
|
+
|
8
|
+
private
|
7
9
|
|
8
10
|
def should_normalize_lastname?
|
9
11
|
true
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: normalizr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dimko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-03-
|
11
|
+
date: 2018-03-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|