daily_affirmation 0.3.2 → 0.3.3

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: 30065f01b099b0b0aee3e2b73232b6bde7f02a36
4
- data.tar.gz: efde73fcb7aa4c2174f58cf5bf80e42adc076171
3
+ metadata.gz: 305ab950efd80d14e92eff86fd045a339a22aa8b
4
+ data.tar.gz: 9afae48904dc91d603ce35cd7a261be311089eb7
5
5
  SHA512:
6
- metadata.gz: 24326312ef59b9a67e04078f03e20c24e0d171caea5e74db4b8602e413cb08b6e665e33aa9acec666f0ddaaa739adc2f6cc790eac7b74bf9f86d5945c9bb4632
7
- data.tar.gz: 0a1cb9a2d89a63ff4990b31b414a86d5f154f5600272586e32d2043039965cf6c7095c7ad503f0782d595c17a7aa3d1360fc261b5e953ccb359d071e65209338
6
+ metadata.gz: 40902db7caf7ddc098d8e2515637bcde4f1a3a47e1c2e854728c80776d85761917803dbf4023cc342d0bc59a8bc2761ce90c0d7b70b690a7eeea8f1eb449dcff
7
+ data.tar.gz: 76486bf174bdaca77ba75b66e5a676b32aa7d9b24c77b839f4de11d5ade12042edd875cc1e5ea486aec5cb3a3088024bae4176f069e1b305c3e90e606ddf4289
@@ -47,7 +47,13 @@ module DailyAffirmation
47
47
  validator = Object.const_get(
48
48
  "DailyAffirmation::Validators::#{type.to_s.capitalize}Validator"
49
49
  )
50
- validator.new(object, attribute, args).affirm
50
+ results = validator.new(object, attribute, args).affirm
51
+
52
+ if args.fetch(:inverse, false)
53
+ [!results[0], results[1]]
54
+ else
55
+ results
56
+ end
51
57
  else
52
58
  [true, nil]
53
59
  end
@@ -1,3 +1,3 @@
1
1
  module DailyAffirmation
2
- VERSION = "0.3.2"
2
+ VERSION = "0.3.3"
3
3
  end
@@ -130,4 +130,20 @@ describe DailyAffirmation do
130
130
  expect(affirmation1).to be_valid
131
131
  expect(affirmation2).to_not be_valid
132
132
  end
133
+
134
+ it "allows each affirmation to be inverted via an :inverse option" do
135
+ cls = Class.new do
136
+ include DailyAffirmation.affirmations
137
+
138
+ affirms_presence_of :name, :inverse => true
139
+ end
140
+
141
+ obj1 = double(:name => nil)
142
+ obj2 = double(:name => :foo)
143
+
144
+ affirmation1 = cls.new(obj1)
145
+ affirmation2 = cls.new(obj2)
146
+ expect(affirmation1).to be_valid
147
+ expect(affirmation2).to_not be_valid
148
+ end
133
149
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: daily_affirmation
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shane Emmons
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-09 00:00:00.000000000 Z
11
+ date: 2014-01-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler