xkeys 2.1.0 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/HISTORY.txt +5 -0
  2. data/lib/xkeys.rb +13 -7
  3. data/xkeys.gemspec +2 -2
  4. metadata +3 -3
@@ -1,3 +1,8 @@
1
+ 2014-05-07 Version 2.2.0
2
+
3
+ Added support for the #xkeys_on_final callback when setting the
4
+ value in the final (leaf) node.
5
+
1
6
  2014-05-06 Version 2.1.0
2
7
 
3
8
  Now works with underlying types that support #[] but not #fetch.
@@ -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, other types with array- or hash-like behavior are
24
- # supported as well.
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.1.0 2014-05-06
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
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "xkeys"
3
- s.version = "2.1.0"
4
- s.date = "2014-05-06"
3
+ s.version = "2.2.0"
4
+ s.date = "2014-05-07"
5
5
  s.authors = ["Brian Katzung"]
6
6
  s.email = ["briank@kappacs.com"]
7
7
  s.homepage = "http://rubygems.org/gems/xkeys"
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 2
7
- - 1
7
+ - 2
8
8
  - 0
9
- version: 2.1.0
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-06 00:00:00 -05:00
17
+ date: 2014-05-07 00:00:00 -05:00
18
18
  default_executable:
19
19
  dependencies: []
20
20