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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/named_hash.rb +7 -5
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b1aaf1d2466d972976c4c84ec8edd47cae3a0395ef0fac9c99385f7d12684e94
4
- data.tar.gz: 20d0799226bf43595b20bc59166203e9a6d5bd6a43bc826053d57612d1d40b04
3
+ metadata.gz: 950b3bc7429667f6d01cd837bf7a1f84976896df775e859f66ceb6fb0d5c75b7
4
+ data.tar.gz: 19bee391724d1c91934f1d4e2a4850509e22a2af30753ab4cbdc393c4c4a0f8f
5
5
  SHA512:
6
- metadata.gz: 891716a2a46c5e413cd1e04e59929150d126cd79196cbb45eaaa45e5022a9c3f2242039d0b93fb13c67e53f54e7ea386263d3357d634add96c451ecb5ec79936
7
- data.tar.gz: d7f106e8f76ee6352000c28e2836786fc8e501beff1d48c9afd555983906b39db9484c9d56ca8d93b1d58d6da6bb08bab54708bf124fdf9f4bfc3bc93b47c384
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 [](key)
23
- check_key_type(key)
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.1.1
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-07-22 00:00:00.000000000 Z
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