casted_hash 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5fbb548f016a133c4d10ff789086c7402e956da1
4
- data.tar.gz: a77641ba09b64407763ce8e547d252dab608b763
3
+ metadata.gz: 0e6fa74a70ab96f305134d7b76f0d09054ab63c8
4
+ data.tar.gz: 015673c797ef268dcc33ead39faf55f5346c9d08
5
5
  SHA512:
6
- metadata.gz: 6a36b6e3d4f058eaa52f8c422aacb5f5a82c8a4a8b95dc3df358536790f2de4accf98a74eec20eb2bdcaac65fb9bd241eb3ff3e6fda037122548fbeb24c059b2
7
- data.tar.gz: be2f8f407d9cbf209ba84761ca849224c3ef8f124a4ae821ff72dc33b9b29d464a59cf31b87875c15fb5d6d4ba674480f676b11909316ab0d77878c073dde6db
6
+ metadata.gz: 12c4c6f1b92d71bcb7c333897fc3ec927e4bc4a7358daff4f85478939b397c638ac939af45a996cb797877f44149d209df983c0e11e71cb6af72d2ac47a8fb69
7
+ data.tar.gz: d7b405bb10596a467c404f0e3891f2af86a5c4b384056a5b3e5aed2b2803d91c65927ecb82e3798404093df0ce055f1fac9432b14aa3a3f24602f96672a2860d
@@ -1,3 +1,3 @@
1
1
  class CastedHash
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
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
@@ -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
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: casted_hash
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephan Kaag