hash-proxy 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +3 -0
- data/README.md +14 -0
- data/lib/hash_proxy/null_object.rb +3 -0
- data/spec/hash_proxy_spec.rb +18 -3
- data/version.txt +1 -1
- metadata +2 -2
data/History.txt
CHANGED
data/README.md
CHANGED
@@ -39,6 +39,17 @@ Also supports hash like semantics:
|
|
39
39
|
puts "#{k}: #{v}"
|
40
40
|
end
|
41
41
|
|
42
|
+
Limitations
|
43
|
+
-----------
|
44
|
+
|
45
|
+
Because it mixes in Enumerable, the Proxy class doesn't play nice with keys whose names correspond to
|
46
|
+
methods on Enumerable. The work around: for keys that are methods on Enumerable, use the hash accessor
|
47
|
+
instead of the method call notation:
|
48
|
+
|
49
|
+
proxy = HashProxy.create_from(:size => 42)
|
50
|
+
proxy.size => 1 (the number of key-value pairs in the proxied Hash)
|
51
|
+
proxy[:size] => 42 (the value pointed to by the :size key)
|
52
|
+
|
42
53
|
Requirements
|
43
54
|
------------
|
44
55
|
|
@@ -70,6 +81,9 @@ Original author: Douglas A. Seifert (doug@dseifert.net)
|
|
70
81
|
History
|
71
82
|
-------
|
72
83
|
|
84
|
+
### Version 0.1.3 / 2012-08-13
|
85
|
+
* Support to_ary method on NullObject
|
86
|
+
|
73
87
|
### Version 0.1.2 / 2012-06-15
|
74
88
|
* Fix bug with hashes with false as a value
|
75
89
|
|
data/spec/hash_proxy_spec.rb
CHANGED
@@ -2,17 +2,32 @@
|
|
2
2
|
require File.expand_path('../spec_helper', __FILE__)
|
3
3
|
|
4
4
|
describe HashProxy do
|
5
|
+
it "works with null values" do
|
6
|
+
proxy = HashProxy.create_from(:null => nil)
|
7
|
+
proxy.size.should eq(1)
|
8
|
+
proxy.null.should be_nil
|
9
|
+
proxy.null.class.should eq(HashProxy::NullObject)
|
10
|
+
proxy.null.to_a.should eq([])
|
11
|
+
proxy.null.to_ary.should eq([])
|
12
|
+
end
|
13
|
+
|
14
|
+
it "works with keys called size" do
|
15
|
+
proxy = HashProxy.create_from(:size => 42, :bar => :foo)
|
16
|
+
proxy.size.should eq(2)
|
17
|
+
proxy[:size].should == 42
|
18
|
+
end
|
19
|
+
|
5
20
|
|
6
21
|
it "handles booleans" do
|
7
22
|
proxy = HashProxy.create_from(:indexed => false, :followed => true)
|
8
|
-
proxy
|
9
|
-
proxy
|
23
|
+
proxy.indexed.should eq(false)
|
24
|
+
proxy.followed.should == true
|
10
25
|
end
|
11
26
|
|
12
27
|
it "does not get confused by methods defined on Kernel" do
|
13
28
|
proxy = HashProxy::Proxy.new({})
|
14
29
|
lambda { proxy[:format] }.should_not raise_error
|
15
|
-
proxy
|
30
|
+
proxy.format.should be_nil
|
16
31
|
end
|
17
32
|
|
18
33
|
it "supports enumerable" do
|
data/version.txt
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.3
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hash-proxy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-08-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bones
|