named_hash 0.1.1 → 0.2
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 +4 -4
- data/lib/named_hash.rb +7 -5
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 950b3bc7429667f6d01cd837bf7a1f84976896df775e859f66ceb6fb0d5c75b7
|
|
4
|
+
data.tar.gz: 19bee391724d1c91934f1d4e2a4850509e22a2af30753ab4cbdc393c4c4a0f8f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2ee7a0f204f740b4eab83946a3d2515567d17cdf27fd150df0ff8f4cb3f8d0033086e269821168d24dada84dc9721515f212f3c6981472316adda60f66af348b
|
|
7
|
+
data.tar.gz: 416fbd6331cbb8c783d5be07602c84099317be5922392f652228138a6174dcbc7ad0851cbab0ab1c2f991edb64fb24d47cb56fe883c7fbdba16eaa7a7f4b0fff
|
data/lib/named_hash.rb
CHANGED
|
@@ -2,7 +2,7 @@ require_relative 'hash'
|
|
|
2
2
|
|
|
3
3
|
class NamedHash < Hash
|
|
4
4
|
def initialize(hash = nil)
|
|
5
|
-
super
|
|
5
|
+
super()
|
|
6
6
|
if hash
|
|
7
7
|
merge(hash)
|
|
8
8
|
end
|
|
@@ -19,11 +19,13 @@ class NamedHash < Hash
|
|
|
19
19
|
alias_method :native_set, :[]=
|
|
20
20
|
alias_method :[]=, :set
|
|
21
21
|
|
|
22
|
-
def
|
|
23
|
-
|
|
24
|
-
super[key.to_s]
|
|
22
|
+
def get(key)
|
|
23
|
+
native_get(key.to_s)
|
|
25
24
|
end
|
|
26
25
|
|
|
26
|
+
alias_method :native_get, :[]
|
|
27
|
+
alias_method :[], :get
|
|
28
|
+
|
|
27
29
|
def merge(hash)
|
|
28
30
|
hash.each do |key, value|
|
|
29
31
|
set(key, value)
|
|
@@ -47,4 +49,4 @@ class NamedHash < Hash
|
|
|
47
49
|
def check_key_type(key)
|
|
48
50
|
raise InvalidKeyError unless (key.is_a?(String) || key.is_a?(Symbol))
|
|
49
51
|
end
|
|
50
|
-
end
|
|
52
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: named_hash
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: '0.2'
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Hampton Lintorn-Catlin <hcatlin@gmail.com>
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2024-
|
|
11
|
+
date: 2024-08-13 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: A new take on HashWithIndifferentAccess
|
|
14
14
|
email: hcatlin@gmail.com
|