casted_hash 0.1.0 → 0.1.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/version.rb +1 -1
- data/lib/casted_hash.rb +3 -1
- data/test/test_casted_hash.rb +10 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0e6fa74a70ab96f305134d7b76f0d09054ab63c8
|
4
|
+
data.tar.gz: 015673c797ef268dcc33ead39faf55f5346c9d08
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 12c4c6f1b92d71bcb7c333897fc3ec927e4bc4a7358daff4f85478939b397c638ac939af45a996cb797877f44149d209df983c0e11e71cb6af72d2ac47a8fb69
|
7
|
+
data.tar.gz: d7b405bb10596a467c404f0e3891f2af86a5c4b384056a5b3e5aed2b2803d91c65927ecb82e3798404093df0ce055f1fac9432b14aa3a3f24602f96672a2860d
|
data/lib/casted_hash/version.rb
CHANGED
data/lib/casted_hash.rb
CHANGED
@@ -8,7 +8,7 @@ class CastedHash
|
|
8
8
|
extend Forwardable
|
9
9
|
attr_reader :cast_proc
|
10
10
|
|
11
|
-
def_delegators :@hash, *[:keys, :inject, :key?, :include?]
|
11
|
+
def_delegators :@hash, *[:keys, :inject, :key?, :include?, :empty?, :any?]
|
12
12
|
def_delegators :casted_hash, *[:collect, :reject]
|
13
13
|
|
14
14
|
def initialize(constructor = {}, cast_proc = nil)
|
@@ -72,6 +72,8 @@ class CastedHash
|
|
72
72
|
end
|
73
73
|
|
74
74
|
def update(other_hash)
|
75
|
+
return unless other_hash.any?
|
76
|
+
|
75
77
|
if other_hash.is_a? CastedHash
|
76
78
|
@hash.update other_hash.pack_hash(self)
|
77
79
|
else
|
data/test/test_casted_hash.rb
CHANGED
@@ -27,6 +27,16 @@ class TestCastedHash < Minitest::Test
|
|
27
27
|
assert !hash.casted?(:b)
|
28
28
|
end
|
29
29
|
|
30
|
+
it "should respond to any? and empty?" do
|
31
|
+
hash = CastedHash.new({}, lambda {})
|
32
|
+
assert hash.empty?
|
33
|
+
assert !hash.any?
|
34
|
+
|
35
|
+
hash = CastedHash.new({:foo => "bar"}, lambda {})
|
36
|
+
assert !hash.empty?
|
37
|
+
assert hash.any?
|
38
|
+
end
|
39
|
+
|
30
40
|
it "should only cast once" do
|
31
41
|
hash = CastedHash.new({:foo => 1}, lambda { |x| x + 1 })
|
32
42
|
|