bogo 0.2.6 → 0.2.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/bogo/smash.rb +14 -4
- data/lib/bogo/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7ec29a67728ffbbaf47b982278ada80c261d31dc
|
4
|
+
data.tar.gz: 4e4fdefbbf834b13f81d1376abe7bb313cc650ed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c5bbed35f2489b6eff54bb7705ea0415b3de11ff3f7579671834ce010128e8aebf5032a193677f803855f5c144c044ff28fbf83675d677267d4d45e9af30402a
|
7
|
+
data.tar.gz: 0b7530c5d0f21a58c14e22266604f3df71ea34c3414c968ef1a4c8adfc365677a627763e5cf9c0327ab33076f6377bfc59f652878b19cfa28343afea29f6920f
|
data/CHANGELOG.md
CHANGED
data/lib/bogo/smash.rb
CHANGED
@@ -83,10 +83,20 @@ module Bogo
|
|
83
83
|
#
|
84
84
|
# @param args [String, Symbol, Object] key path to walk. last value default to return
|
85
85
|
# @return [Object] value at key or default value
|
86
|
-
def fetch(*args)
|
87
|
-
|
88
|
-
|
89
|
-
|
86
|
+
def fetch(*args, &block)
|
87
|
+
if(block_given?)
|
88
|
+
default_value = block
|
89
|
+
elsif(args.size > 1)
|
90
|
+
default_value = args.pop
|
91
|
+
elsif(args.size < 1)
|
92
|
+
raise ArgumentError.new("Default value must be provided for #fetch")
|
93
|
+
end
|
94
|
+
result = retrieve(*args)
|
95
|
+
if(result == NO_VALUE)
|
96
|
+
block_given? ? default_value.call(self) : default_value
|
97
|
+
else
|
98
|
+
result
|
99
|
+
end
|
90
100
|
end
|
91
101
|
|
92
102
|
# Set value at given path
|
data/lib/bogo/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bogo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Roberts
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-01-
|
11
|
+
date: 2017-01-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hashie
|