casted_hash 0.8.0 → 0.8.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 +10 -9
- 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: 50e91b47f2183e145bf15c2f98b9c226f54f0f7b
|
4
|
+
data.tar.gz: 6f9ad44cb0d894e88cd7ee5a3d1ecb1400db1197
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e3c431b50dfeef9412ba54ac62896978edf6a2aa050e16b8d61fe38c856736227e8f7628c0b11262f2ae8945b7fbf862a292d0af26ae4d93388df76c015bb476
|
7
|
+
data.tar.gz: 5e68e7c4468f8583796a2363965fa8b763ff9c470d898eea9b12c567c5cc1330a074a3c74a50bead0c9f50969e7ae888274919c127b66e5a34e14efedb26d6cd
|
data/lib/casted_hash.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
class CastedHash < Hash
|
2
|
-
VERSION = "0.8.
|
2
|
+
VERSION = "0.8.1"
|
3
3
|
|
4
4
|
def initialize(constructor = {}, cast_proc = nil)
|
5
5
|
raise ArgumentError, "`cast_proc` required" unless cast_proc
|
@@ -47,13 +47,16 @@ class CastedHash < Hash
|
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
|
-
alias_method :
|
50
|
+
alias_method :original_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
|
+
|
53
57
|
def []=(key, value)
|
54
|
-
|
55
|
-
|
56
|
-
regular_writer(key, value)
|
58
|
+
uncast! convert_key(key)
|
59
|
+
regular_writer key, value
|
57
60
|
end
|
58
61
|
|
59
62
|
alias_method :store, :[]=
|
@@ -66,14 +69,12 @@ class CastedHash < Hash
|
|
66
69
|
return self if other_hash.empty?
|
67
70
|
|
68
71
|
other_hash.each_pair do |key, value|
|
69
|
-
|
70
|
-
|
71
|
-
regular_writer converted_key, value
|
72
|
+
regular_writer key, value
|
72
73
|
|
73
74
|
if other_hash.is_a?(CastedHash) && other_hash.casted?(key)
|
74
75
|
casted!(key)
|
75
76
|
elsif casted?(key)
|
76
|
-
uncast!(
|
77
|
+
uncast!(convert_key(key))
|
77
78
|
end
|
78
79
|
end
|
79
80
|
|