casted_hash 0.8.1 → 0.8.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/casted_hash.rb +9 -10
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 50e91b47f2183e145bf15c2f98b9c226f54f0f7b
4
- data.tar.gz: 6f9ad44cb0d894e88cd7ee5a3d1ecb1400db1197
3
+ metadata.gz: 51538dc53f9101fbf596ee33c22b9ccdab73b1dd
4
+ data.tar.gz: 07c4992f7b510b61c350d6f4a608b042edf4e28f
5
5
  SHA512:
6
- metadata.gz: e3c431b50dfeef9412ba54ac62896978edf6a2aa050e16b8d61fe38c856736227e8f7628c0b11262f2ae8945b7fbf862a292d0af26ae4d93388df76c015bb476
7
- data.tar.gz: 5e68e7c4468f8583796a2363965fa8b763ff9c470d898eea9b12c567c5cc1330a074a3c74a50bead0c9f50969e7ae888274919c127b66e5a34e14efedb26d6cd
6
+ metadata.gz: c759b992fae0deb246f331204fcb585b79526df69fe8490b7ffb85d2bad03fa0c853062ae38263c4919a268035f06d2da8296887bbf21648b22f3d2284f0f1c0
7
+ data.tar.gz: f309b99ed5fa61b30502dde40f788c4957de317948e513b56cdf3bfeb40a03ba3218c590af24e488d156ce47a477db8995799572ff34420c8757ceb80d3ab92c
data/lib/casted_hash.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  class CastedHash < Hash
2
- VERSION = "0.8.1"
2
+ VERSION = "0.8.2"
3
3
 
4
4
  def initialize(constructor = {}, cast_proc = nil)
5
5
  raise ArgumentError, "`cast_proc` required" unless cast_proc
@@ -47,16 +47,13 @@ class CastedHash < Hash
47
47
  end
48
48
  end
49
49
 
50
- alias_method :original_regular_writer, :[]=
50
+ alias_method :regular_writer, :[]= unless method_defined?(:regular_writer)
51
51
  alias_method :regular_update, :update unless method_defined?(:regular_update)
52
52
 
53
- def regular_writer(key, value)
54
- original_regular_writer(convert_key(key), value)
55
- end
56
-
57
53
  def []=(key, value)
58
- uncast! convert_key(key)
59
- regular_writer key, value
54
+ key = convert_key(key)
55
+ uncast! key
56
+ regular_writer(key, value)
60
57
  end
61
58
 
62
59
  alias_method :store, :[]=
@@ -69,12 +66,14 @@ class CastedHash < Hash
69
66
  return self if other_hash.empty?
70
67
 
71
68
  other_hash.each_pair do |key, value|
72
- regular_writer key, value
69
+ converted_key = convert_key(key)
70
+
71
+ regular_writer converted_key, value
73
72
 
74
73
  if other_hash.is_a?(CastedHash) && other_hash.casted?(key)
75
74
  casted!(key)
76
75
  elsif casted?(key)
77
- uncast!(convert_key(key))
76
+ uncast!(converted_key)
78
77
  end
79
78
  end
80
79
 
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.8.1
4
+ version: 0.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephan Kaag
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-03 00:00:00.000000000 Z
11
+ date: 2016-05-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler