xkeys 2.1.0 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/HISTORY.txt +5 -0
- data/lib/xkeys.rb +13 -7
- data/xkeys.gemspec +2 -2
- metadata +3 -3
data/HISTORY.txt
CHANGED
data/lib/xkeys.rb
CHANGED
@@ -20,17 +20,14 @@
|
|
20
20
|
# root[1, 0, {}] # => 'value 1'
|
21
21
|
# root[1, 4, {}] # => nil
|
22
22
|
#
|
23
|
-
# As of version 2.0.0,
|
24
|
-
# supported
|
25
|
-
#
|
26
|
-
# As of version 2.0.0, underlying types must implement #[], #[]=, and
|
27
|
-
# #fetch to be supported (see the Array or Hash class documentation).
|
28
|
-
# They must also implement #push if you want to use push mode (index ":[]").
|
23
|
+
# As of version 2.0.0, any underlying type implementing #[], #[]= (if
|
24
|
+
# setting), #fetch, and #push (if using push mode) is supported. (See the
|
25
|
+
# Array documentation.)
|
29
26
|
#
|
30
27
|
# As of version 2.1.0, #[] is used if #fetch is not supported. Missing-key
|
31
28
|
# detection (still) depends on KeyError or IndexError being raised.
|
32
29
|
#
|
33
|
-
# Version 2.
|
30
|
+
# Version 2.2.0 2014-05-07
|
34
31
|
#
|
35
32
|
# @author Brian Katzung <briank@kappacs.com>, Kappa Computer Solutions, LLC
|
36
33
|
# @copyright 2013-2014 Brian Katzung and Kappa Computer Solutions, LLC
|
@@ -141,6 +138,11 @@ module XKeys::Set_
|
|
141
138
|
# push mode has not been disabled (see below), a new node will be
|
142
139
|
# pushed onto the end of the current node.
|
143
140
|
#
|
141
|
+
# If the root of the tree responds to the #xkeys_on_final method, it
|
142
|
+
# will be called as follows before the (final leaf) assignment:
|
143
|
+
#
|
144
|
+
# xkeys_on_final(leaf_node, key, value, option_hash)
|
145
|
+
#
|
144
146
|
# Options:
|
145
147
|
#
|
146
148
|
# :[] => false
|
@@ -153,6 +155,8 @@ module XKeys::Set_
|
|
153
155
|
push_mode = options[:[]] != false
|
154
156
|
|
155
157
|
if args.count + last == 0
|
158
|
+
xkeys_on_final self, args[0], args[-1], options if
|
159
|
+
respond_to? :xkeys_on_final
|
156
160
|
if args[0] == :[] && push_mode && respond_to?(:push)
|
157
161
|
push args[-1] # array[:[]] = value
|
158
162
|
true # done--don't caller-super
|
@@ -180,6 +184,8 @@ module XKeys::Set_
|
|
180
184
|
end
|
181
185
|
|
182
186
|
# Assign (or push) according to the final key.
|
187
|
+
xkeys_on_final node, args[0], args[-1], options if
|
188
|
+
respond_to? :xkeys_on_final
|
183
189
|
if key == :[] && push_mode && node.respond_to?(:push)
|
184
190
|
node.push args[-1]
|
185
191
|
else
|
data/xkeys.gemspec
CHANGED
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 2
|
7
|
-
-
|
7
|
+
- 2
|
8
8
|
- 0
|
9
|
-
version: 2.
|
9
|
+
version: 2.2.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Brian Katzung
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2014-05-
|
17
|
+
date: 2014-05-07 00:00:00 -05:00
|
18
18
|
default_executable:
|
19
19
|
dependencies: []
|
20
20
|
|