ensurance 0.1.2 → 0.1.3

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: 8eb671568b29b89cf20287832d8387769ed8848a
4
- data.tar.gz: dfc080f66aee9df634277134db7ff61914afdf96
3
+ metadata.gz: 01f514ba5f0eef829157408e664c9e5156b2058e
4
+ data.tar.gz: 491475ddd8df0c8fe9f6044015ec4bb08953f47a
5
5
  SHA512:
6
- metadata.gz: 56351b09931c81edce4f1a30e0496e19feb6e330d538e6977b39375c4f7cb7f2ce8d9918ab8d26d12db9cc765b789ba3522c65b14c5e92b3c1647dc812e7b289
7
- data.tar.gz: 3c65be266c128ed5ba7a440a20614233dee766e99ed9ad1ea0a7cf99c1c3f08dba9a9cb03382c35cb4a5c61c82a1234a588442c704ea07f185b57f45aba42990
6
+ metadata.gz: 771842cca4e6ca4ffb2801d62bef28dc494278f580e52131051e93bab6e55675453986c81c6b2ad8419cdf3485f5c98fcb248ad28a8ff222e522ab623c7fdcc1
7
+ data.tar.gz: a7868bd6816f1719de2cf547bc0584ed5eff89137eb089359dff8dd54bc096f9952598920e60d48a02f2b43b18dbb606a754b2c24efd1d7c8ca50d008d711b98
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ensurance (0.1.1)
4
+ ensurance (0.1.2)
5
5
  activesupport (>= 3, < 6)
6
6
 
7
7
  GEM
data/lib/ensurance.rb CHANGED
@@ -10,8 +10,8 @@ module Ensurance
10
10
 
11
11
  class_methods do
12
12
  def ensure_by(*args)
13
- @_ensure_by ||= [:id]
14
- @_ensure_by += [args].flatten
13
+ @_additional_ensure_by = args
14
+ @_ensure_by = nil
15
15
  end
16
16
 
17
17
  def ensure(thing = nil)
@@ -28,7 +28,7 @@ module Ensurance
28
28
  end
29
29
  found = nil
30
30
 
31
- @_ensure_by ||= [:id]
31
+ @_ensure_by ||= [self.primary_key, @_additional_ensure_by].flatten.compact.uniq
32
32
  @_ensure_by.each do |ensure_field|
33
33
  value = thing.try(:fetch, ensure_field.to_sym, nil) || thing.try(:fetch, ensure_field.to_s, nil) || thing
34
34
  found = self.find_by(ensure_field => value)
@@ -1,3 +1,3 @@
1
1
  module Ensurance
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ensurance
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Sharpe
@@ -151,7 +151,6 @@ files:
151
151
  - bin/setup
152
152
  - ensurance-0.1.0.gem
153
153
  - ensurance.gemspec
154
- - file:memdb1?mode=memory&cache=shared
155
154
  - lib/ensurance.rb
156
155
  - lib/ensurance/date_ensure.rb
157
156
  - lib/ensurance/hash_ensure.rb
Binary file