hash-proxy 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,6 @@
1
+ # == Version 0.1.2 / 2012-06-15
2
+ # * Fix bug for hashes with false as a value
3
+ #
1
4
  # == Version 0.1.1 / 2012-06-12
2
5
  # * Work around weird behavior when using [] method
3
6
  # to access keys which are methods defined on Kernel,
data/README.md CHANGED
@@ -67,6 +67,36 @@ Author
67
67
 
68
68
  Original author: Douglas A. Seifert (doug@dseifert.net)
69
69
 
70
+ History
71
+ -------
72
+
73
+ ### Version 0.1.2 / 2012-06-15
74
+ * Fix bug with hashes with false as a value
75
+
76
+ ### Version 0.1.1 / 2012-06-12
77
+ * Work around weird behavior when using [] method
78
+ to access keys which are methods defined on Kernel,
79
+ like Kernel#format. TODO: inherit from BasicObject to
80
+ avoid this?
81
+
82
+ ### Version 0.1.0 / 2012-06-12
83
+ * include Enumerable in Proxy
84
+ * Add some hash-like semantics to Proxy
85
+
86
+ ### Version 0.0.4 / 2012-06-08
87
+ * Add #to_str to NullObject to avoid some rspec errors
88
+
89
+ ### Version 0.0.3 / 2012-06-08
90
+ * Fix homepage in gemspec
91
+
92
+ ### Version 0.0.2 / 2012-06-08
93
+ * Convert to yard doc for "rake doc" task.
94
+ * Handle respond_to? in a sensible fashion.
95
+
96
+ ### Version 0.0.1 / 2012-06-07
97
+ * First release of hash-proxy
98
+ * Handle respond_to? in a sensible fashion.
99
+
70
100
  License
71
101
  -------
72
102
 
@@ -124,14 +124,21 @@ module HashProxy
124
124
  when Hash
125
125
  Proxy.new(value)
126
126
  else
127
- value || NO_OBJECT
127
+ value.nil? ? NO_OBJECT : value
128
128
  end
129
129
  end
130
130
 
131
131
  # moves a value from the original hash to the converted
132
132
  # hash after converting the value to a proxy if necessary
133
133
  def move_value(name, name_str = name.to_s)
134
- @converted[name] = self.convert_value(@hash.delete(name) || @hash.delete(name_str))
134
+ unconverted = if @hash.has_key?(name)
135
+ @hash.delete(name)
136
+ elsif @hash.has_key?(name_str)
137
+ @hash.delete(name_str)
138
+ else
139
+ nil
140
+ end
141
+ @converted[name] = self.convert_value(unconverted)
135
142
  end
136
143
 
137
144
  end
@@ -2,6 +2,13 @@
2
2
  require File.expand_path('../spec_helper', __FILE__)
3
3
 
4
4
  describe HashProxy do
5
+
6
+ it "handles booleans" do
7
+ proxy = HashProxy.create_from(:indexed => false, :followed => true)
8
+ proxy[:indexed].should == false
9
+ proxy[:followed].should == true
10
+ end
11
+
5
12
  it "does not get confused by methods defined on Kernel" do
6
13
  proxy = HashProxy::Proxy.new({})
7
14
  lambda { proxy[:format] }.should_not raise_error
data/version.txt CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
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.1
4
+ version: 0.1.2
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-06-12 00:00:00.000000000 Z
12
+ date: 2012-06-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bones