casted_hash 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/casted_hash.rb +2 -2
- data/test/test_casted_hash.rb +5 -2
- 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: 2766e44c7cab47d5330284c6277d51f28ede5436
|
4
|
+
data.tar.gz: 44787b63218ed0b0da0dea2f20bffd97c94e8649
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7d1b9bb7ff8d5bf2e730fb825bacd7643f98b262731a20838a466539842c681d32fa97dc1e06c5d3a5096888a81521bd43931173f678d0d5671cb13e6d48c4fc
|
7
|
+
data.tar.gz: 5ac7495d36dcb79f6f6314190de38332075f1a8f87a7c21967cb6cb3a0a8fc6b7211248b582cff1a7c5dcc5ef4a08cca954c501260d40b254330576b39781aee
|
data/lib/casted_hash.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
class CastedHash < Hash
|
2
|
-
VERSION = "0.2.
|
2
|
+
VERSION = "0.2.1"
|
3
3
|
|
4
4
|
def initialize(constructor = {}, cast_proc = nil)
|
5
5
|
raise ArgumentError, "`cast_proc` required" unless cast_proc
|
@@ -8,7 +8,7 @@ class CastedHash < Hash
|
|
8
8
|
|
9
9
|
if constructor.is_a?(CastedHash)
|
10
10
|
super()
|
11
|
-
@casted_keys = constructor.instance_variable_get(:@casted_keys)
|
11
|
+
@casted_keys = constructor.instance_variable_get(:@casted_keys).dup
|
12
12
|
regular_update(constructor)
|
13
13
|
elsif constructor.is_a?(Hash)
|
14
14
|
@casted_keys = []
|
data/test/test_casted_hash.rb
CHANGED
@@ -97,7 +97,7 @@ describe CastedHash do
|
|
97
97
|
end
|
98
98
|
|
99
99
|
it "takes over scope when merging two casted hashes" do
|
100
|
-
hash1 = CastedHash.new({:a => 1, :b => 2}, lambda {|x| x + 10 })
|
100
|
+
hash1 = CastedHash.new({:a => 1, :b => 2, :z => 0}, lambda {|x| x + 10 })
|
101
101
|
hash2 = CastedHash.new({:a => 2, :c => 3, :d => 4}, lambda {|x| x + 100 })
|
102
102
|
|
103
103
|
assert_equal 11, hash1[:a]
|
@@ -108,7 +108,10 @@ describe CastedHash do
|
|
108
108
|
|
109
109
|
hash3 = hash1.merge hash2
|
110
110
|
|
111
|
-
assert_equal
|
111
|
+
assert_equal 10, hash3[:z]
|
112
|
+
assert !hash1.casted?(:z)
|
113
|
+
|
114
|
+
assert_equal ["a", "b", "c", "d", "z"], hash3.keys.sort
|
112
115
|
assert !hash3.casted?(:a)
|
113
116
|
assert hash3.casted?(:b)
|
114
117
|
assert !hash3.casted?(:c)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: casted_hash
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stephan Kaag
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-01-
|
11
|
+
date: 2014-01-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|