open_hash 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/lib/open_hash.rb +20 -4
  4. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9cabb37696a38c934c8530c7529961510fb6e186ca3a1303f61764099754b5f7
4
- data.tar.gz: f0aa05e2b21858e80d3ac82ee9180d4128fbd18f14213f99b30890723148fc12
3
+ metadata.gz: 13454c621c7953de66e52401787727571d0c857afed15a06d305d185bb89c915
4
+ data.tar.gz: e6acbd3d815e4223752a8f7b996e28a883bc4e1827aa7a158c946ad2681ecebd
5
5
  SHA512:
6
- metadata.gz: 405250c6c97f8d26a2fb07a35bf2645968e0e7d745da23e98971dbd5b4199d0eff7e2156feb249196447ef7aff9912ecf9a9e9fc54a0b86a6a18f71594de7a58
7
- data.tar.gz: 739af567badac7eb1f6cccf5f409f89929f785a9e98327e7b5c4976d626624e358e27f6dcf4defe18ffa06ae9cc7057ef70b8b449257792bc81e5eb360028c87
6
+ metadata.gz: 3041f5798d8f347716f5302fe632a2bab7536a3890f4df49dd4ef452a338d5478792907ccbca3c9b73bf1aa3df94ab16d5945de8eec662887481846f6666ca45
7
+ data.tar.gz: 17b25b59e6c319e99a45d2a8793beabaa4d55301f83d93c9056b6c37a25de952225400aa747349535a8950c4abd127e1343dcba6d62e356366f26281b6bcb292
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- open_hash (0.2.0)
4
+ open_hash (0.2.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/lib/open_hash.rb CHANGED
@@ -9,7 +9,9 @@ class OpenHash < Hash
9
9
  end
10
10
 
11
11
  def method_missing(method_name, *args, &block)
12
- if has_key?(method_name)
12
+ if method_name.to_s.end_with?("?")
13
+ has_key?(method_name.to_s.chomp("?").to_sym) || has_key?(method_name.to_s.chomp("?"))
14
+ elsif has_key?(method_name)
13
15
  self[method_name]
14
16
  elsif has_key?(method_name.to_s)
15
17
  self[method_name.to_s]
@@ -21,17 +23,31 @@ class OpenHash < Hash
21
23
  end
22
24
 
23
25
  def methods
24
- setter_keys = keys.map { |key| "#{key}=".to_sym }
25
- super + keys.map(&:to_sym) + setter_keys
26
+ super + setter_methods + getter_methods + predicate_methods
26
27
  end
27
28
 
28
29
  module VERSION
29
30
  MAJOR = 0
30
31
  MINOR = 2
31
- TINY = 0
32
+ TINY = 1
32
33
 
33
34
  STRING = [MAJOR, MINOR, TINY].compact.join(".")
34
35
  end
36
+
37
+
38
+ private
39
+
40
+ def setter_methods
41
+ keys.map { |key| "#{key}=".to_sym }
42
+ end
43
+
44
+ def getter_methods
45
+ keys.map(&:to_sym)
46
+ end
47
+
48
+ def predicate_methods
49
+ keys.map { |key| "#{key}?".to_sym }
50
+ end
35
51
  end
36
52
 
37
53
  class Hash
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: open_hash
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Reegan Viljoen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-07-01 00:00:00.000000000 Z
11
+ date: 2023-08-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
@@ -75,7 +75,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
75
75
  - !ruby/object:Gem::Version
76
76
  version: '0'
77
77
  requirements: []
78
- rubygems_version: 3.4.12
78
+ rubygems_version: 3.4.1
79
79
  signing_key:
80
80
  specification_version: 4
81
81
  summary: Hashes with keys and methods!