Package not found. Please check the package name and try again.
named_hash 0.1.0 → 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/hash.rb +1 -0
- data/lib/named_hash.rb +11 -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/hash.rb
CHANGED
data/lib/named_hash.rb
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
require_relative 'hash'
|
|
2
|
+
|
|
1
3
|
class NamedHash < Hash
|
|
2
4
|
def initialize(hash = nil)
|
|
3
|
-
super
|
|
5
|
+
super()
|
|
4
6
|
if hash
|
|
5
7
|
merge(hash)
|
|
6
8
|
end
|
|
@@ -13,14 +15,17 @@ class NamedHash < Hash
|
|
|
13
15
|
end
|
|
14
16
|
native_set(key.to_s, value)
|
|
15
17
|
end
|
|
18
|
+
|
|
16
19
|
alias_method :native_set, :[]=
|
|
17
20
|
alias_method :[]=, :set
|
|
18
21
|
|
|
19
|
-
def
|
|
20
|
-
|
|
21
|
-
super(key.to_s)
|
|
22
|
+
def get(key)
|
|
23
|
+
native_get(key.to_s)
|
|
22
24
|
end
|
|
23
25
|
|
|
26
|
+
alias_method :native_get, :[]
|
|
27
|
+
alias_method :[], :get
|
|
28
|
+
|
|
24
29
|
def merge(hash)
|
|
25
30
|
hash.each do |key, value|
|
|
26
31
|
set(key, value)
|
|
@@ -30,6 +35,7 @@ class NamedHash < Hash
|
|
|
30
35
|
def to_named_hash
|
|
31
36
|
self
|
|
32
37
|
end
|
|
38
|
+
|
|
33
39
|
alias :~ :to_named_hash
|
|
34
40
|
|
|
35
41
|
class InvalidKeyError < StandardError
|
|
@@ -43,4 +49,4 @@ class NamedHash < Hash
|
|
|
43
49
|
def check_key_type(key)
|
|
44
50
|
raise InvalidKeyError unless (key.is_a?(String) || key.is_a?(Symbol))
|
|
45
51
|
end
|
|
46
|
-
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
|