nested_hash_builder 0.1.0 → 0.1.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '03238f7b928506bf5341118b4436d3aad87ada5ba3c686b4779425ba8d0c46db'
4
- data.tar.gz: 9dc3320dca3c8f6e2b1fe8c2f9df430ae7636110f92250db8e8e9aefdae32e48
3
+ metadata.gz: 27e48078e46d2370f254af47a5af0b815c761e2bd24179d6cd45f84f707241b7
4
+ data.tar.gz: 7ee2bce52dd09cc3ce9ffa1e7511cbfc33c081ede01a58a857176f0eb9f854e8
5
5
  SHA512:
6
- metadata.gz: a92b4f9fdad9763c7304caaa141e7893f984bdc6fbc754a941891e4e0c4dc1b18387c97204cca7056d492d23afabf9b2d1c6037b35aa562480dfc44e2f047c1c
7
- data.tar.gz: '068689310d882ca23447531ea9a2cc919ec3de80db0546e63609a3673e0be7a23a018901d41b83d10d744b4a738e10e583ad1669a6ff97f7769359dec09eedc8'
6
+ metadata.gz: 4137fe58376f5edec945a7fc216eb14a5b6081bae71334107ebb56c25963ce185c7f9bbe39c9dc4b4488a665c5a98f52544440ad6e4484303b513ba2d173f3c3
7
+ data.tar.gz: 60c2ce72259961abe8d7d7b995616f25cef72cf1357ddb3ed7c4f8cfddbe7279ec8f6ba2c72d463405f6fd116650e6b2d89f8264088261a731deaa174920134c
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.4.5
@@ -2,5 +2,5 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module NestedHashBuilder
5
- VERSION = '0.1.0'
5
+ VERSION = '0.1.1'
6
6
  end
@@ -31,9 +31,15 @@ module NestedHashBuilder
31
31
  alias build call
32
32
  end
33
33
 
34
+ module ProxyConstants
35
+ T = ::T
36
+ end
37
+
34
38
  # Object that is the receiver of all
35
39
  # the building methods.
36
40
  class Proxy < ::BasicObject
41
+ include ProxyConstants
42
+
37
43
  #: (?base: Hash[untyped, untyped], ?symbolize: bool) -> void
38
44
  def initialize(base: {}, symbolize: true)
39
45
  @hash = base.dup
@@ -123,7 +129,7 @@ module NestedHashBuilder
123
129
  # @param names [Array<Symbol>]
124
130
  #: (*Symbol | String) -> bool
125
131
  def key?(*names)
126
- !::T.unsafe(self).dig!(*names).nil?
132
+ !T.unsafe(self).dig!(*names).nil?
127
133
  end
128
134
 
129
135
  # Gets a value of a particular key in the current context.
@@ -154,7 +160,7 @@ module NestedHashBuilder
154
160
  #
155
161
  #: (*Symbol | String) -> bool
156
162
  def local_key?(*names)
157
- !::T.unsafe(self).local_dig!(*names).nil?
163
+ !T.unsafe(self).local_dig!(*names).nil?
158
164
  end
159
165
 
160
166
  #: -> Hash[Symbol | String, untyped]
@@ -162,14 +168,20 @@ module NestedHashBuilder
162
168
  @hash
163
169
  end
164
170
 
171
+ private
172
+
173
+ def builder_method?(name)
174
+ !name.end_with?('?') && !name.end_with?('!')
175
+ end
176
+
165
177
  def method_missing(method_name, *args, &block)
166
- super if method_name.end_with?('?') || method_name.end_with?('!')
178
+ super unless builder_method?(method_name)
167
179
 
168
180
  key!(method_name, args.first, &block)
169
181
  end
170
182
 
171
183
  def respond_to_missing?(method_name, *_args)
172
- return false if method_name.end_with?('?') || method_name.end_with?('!')
184
+ return false if builder_method?(method_name)
173
185
 
174
186
  true
175
187
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nested_hash_builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mateusz Drewniak
@@ -31,6 +31,7 @@ extensions: []
31
31
  extra_rdoc_files: []
32
32
  files:
33
33
  - ".github/workflows/ci.yml"
34
+ - ".ruby-version"
34
35
  - CHANGELOG.md
35
36
  - README.md
36
37
  - Rakefile