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.
- checksums.yaml +4 -4
- data/lib/casted_hash.rb +9 -10
- 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: 51538dc53f9101fbf596ee33c22b9ccdab73b1dd
|
4
|
+
data.tar.gz: 07c4992f7b510b61c350d6f4a608b042edf4e28f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
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 :
|
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
|
-
|
59
|
-
|
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
|
-
|
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!(
|
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.
|
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-
|
11
|
+
date: 2016-05-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|