dbla 0.0.7 → 0.0.8

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: 46375a579a4844b2e5b03c9ee9bc2f32091f7085
4
- data.tar.gz: 1b71db3ae756939c2404cc0511cb0b6b354746c4
3
+ metadata.gz: 7a9d166f21b64fbaab705cec213e50b94aeb253e
4
+ data.tar.gz: 4669e265f650ec57bb0d5d3323f3ea6b488c5c79
5
5
  SHA512:
6
- metadata.gz: d08d8af66f5ba45af228082c556384edb75b45a78375e2f5b78bf42f0358f30a703d985316d97628e0565875be3570d9f2d992aafca490f419dd56d1877cfa62
7
- data.tar.gz: 3dda719b6a749db423e10ca3d6e42566c030e0c0dd254a26d3f2ad569b7646f24d40d868cffb9dfbdea69ee5edcb0672b57f86e5aaebde5a9a7ada4238020e8a
6
+ metadata.gz: ce5c08a0345ff246d42fb7cc196bd9afe6506f3e35a5a666327bb5f363a4780fb2b7558ec80d006bd0cf8f3a077ee70b16288ae5ee2d5edccb7181f54266ca8a
7
+ data.tar.gz: 837cdd286e978c92fb832b1fa3eed7c881a8c8513542936015334162d12ef018c7a95ceec16bf41a5fadb1ae539ae81decd1d63b8b96cf84cfc001753d76b1f3
@@ -4,7 +4,7 @@ module Dbla
4
4
  def [] *args
5
5
  if args.first && args.first.to_s.index('.')
6
6
  keys = args.first.to_s.split('.')
7
- keys.inject(_source) do |m,key|
7
+ r = keys.inject(_source) do |m,key|
8
8
  # Array() has a special behavior we do not want for hashes
9
9
  m = (m.is_a? Array) ? m : [m]
10
10
  m.inject([]) do |m2, a|
@@ -22,12 +22,13 @@ module Dbla
22
22
  end
23
23
  end
24
24
  end
25
+ r.blank? ? nil : r
25
26
  else
26
27
  _source.send :[], *args
27
28
  end
28
29
  end
29
30
  def fetch(field, default)
30
- (r = self[field]).empty? ? default : r
31
+ (r = self[field]).blank? ? default : r
31
32
  end
32
33
  def has? f, *values
33
34
  if values.empty?
@@ -1,3 +1,3 @@
1
1
  module Dbla
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
@@ -24,9 +24,11 @@ describe Dbla::Document do
24
24
  describe "[]" do
25
25
  it do
26
26
  expect(subject['foo']).to eql('bar')
27
+ expect(subject['fob']).to eql(nil)
27
28
  expect(subject['lol']).to eql(['wut', 'no'])
28
29
  expect(subject['o.hai.rly']).to eql(['yarly','norly'])
29
- expect(subject['o.hai.wut']).to eql([])
30
+ expect(subject['o.hai.wut']).to eql(nil)
31
+ expect(subject['p.hai.wut']).to eql(nil)
30
32
  end
31
33
  end
32
34
  describe "fetch" do
@@ -37,10 +39,12 @@ describe Dbla::Document do
37
39
  describe "has?" do
38
40
  it "should work with only a key" do
39
41
  expect(subject.has? 'foo').to eql(true)
42
+ expect(subject.has? 'fob').to eql(false)
40
43
  expect(subject.has? 'o.hai.rly').to eql(true)
41
44
  expect(subject.has? 'o.hai.rly','norly').to eql(true)
42
45
  expect(subject.has? 'o.hai.rly','gnarly').to eql(false)
43
46
  expect(subject.has? 'o.hai.wut').to eql(false)
47
+ expect(subject.has? 'p.hai.wut').to eql(false)
44
48
  end
45
49
  it "should work with a value" do
46
50
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dbla
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Audrey Altman