resource-struct 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a61800df441acd7f512f708b4830412edf391047be95e29e8c3e002d8684caf4
4
- data.tar.gz: dc26ed248afa3f648cc4369225bb402eccf28d74f9770ff1a8f39de088009897
3
+ metadata.gz: 7dae7c6c56053d571217150d28f4f70dc6c8c28524d360460e328d09034c17ea
4
+ data.tar.gz: 85a4dc5b15dcb2af42f30ad4e9daa66e3e16b727934305c46e06536a23e6a90c
5
5
  SHA512:
6
- metadata.gz: cd6e55f3a2cd859a37e6fef45485c322f83c8bcbfb6e1df97f4d69e594d77ddbff42668a07bec7438aa0483382e52d26f4ede84162be611cf98ca40b0be3b8b3
7
- data.tar.gz: 4ff5a6edcb9dd6e07c4c3c5744d6e56aaefc14593d3acf6cd7fa9aeee25210656595d7ba926f3e0884265328604b01f5eba35ece222233f248244097813b2beb
6
+ metadata.gz: 781fab03b76d80ba0169635168f46e5cefef893ea7f9dd0a15d5dbed1c9dc211b7ebfef024288f2335a1d3dd50bd920b056b22f7e23d0d2ebddae0178b32b6f6
7
+ data.tar.gz: 64b857102c619e60462d4919021735162c2c991e4bb65ad5096576af4620f866c15b91dbff3062cc1494aa1c94c05d4e29fbe9ad5745f895468e8d0ed80a232a
data/.rubocop.yml CHANGED
@@ -16,7 +16,7 @@ Metrics/MethodLength:
16
16
  Max: 20
17
17
 
18
18
  Metrics/AbcSize:
19
- Max: 25
19
+ Max: 30
20
20
 
21
21
  Metrics/CyclomaticComplexity:
22
22
  Max: 15
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.3.3] - 2022-01-05
4
+ ### Fix
5
+ - Support false values correctly, instead of returning nil
6
+ - Support `respond_to?` properly on `FlexStruct`
7
+
3
8
  ## [0.3.2] - 2022-01-05
4
9
  ### Fix
5
10
  - Support for proper marshalling of object
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- resource-struct (0.3.2)
4
+ resource-struct (0.3.3)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -35,10 +35,12 @@ module ResourceStruct
35
35
  result =
36
36
  if @ro_struct.key?(ckey)
37
37
  @ro_struct[ckey]
38
- elsif key.is_a?(String)
39
- @ro_struct[ckey] = ___convert_value(@hash[key] || @hash[key.to_sym])
40
- else
41
- @ro_struct[ckey] = ___convert_value(@hash[key] || @hash[ckey])
38
+ elsif @hash.key?(key)
39
+ @ro_struct[ckey] = ___convert_value(@hash[key])
40
+ elsif key.is_a?(String) && @hash.key?(key.to_sym)
41
+ @ro_struct[ckey] = ___convert_value(@hash[key.to_sym])
42
+ elsif key.is_a?(Symbol) && @hash.key?(key.to_s)
43
+ @ro_struct[ckey] = ___convert_value(@hash[key.to_s])
42
44
  end
43
45
 
44
46
  return result if sub_keys.empty?
@@ -76,7 +78,9 @@ module ResourceStruct
76
78
  end
77
79
 
78
80
  def ___key?(key)
79
- @hash.key?(key) || @hash.key?(___convert_key(key))
81
+ @hash.key?(key) ||
82
+ @hash.key?(___convert_key(key)) ||
83
+ key.is_a?(String) && @hash.key?(key.to_sym)
80
84
  end
81
85
 
82
86
  def ___convert_key(key)
@@ -27,8 +27,10 @@ module ResourceStruct
27
27
 
28
28
  if @hash.key?(key)
29
29
  @hash[key] = value
30
- elsif key.is_a?(String) || key.is_a?(Symbol) && @hash.key?(key.to_sym)
30
+ elsif key.is_a?(String) && @hash.key?(key.to_sym)
31
31
  @hash[key.to_sym] = value
32
+ elsif key.is_a?(Symbol) && @hash.key?(key.to_s)
33
+ @hash[key.to_s] = value
32
34
  else
33
35
  @hash[key] = value
34
36
  end
@@ -43,8 +45,8 @@ module ResourceStruct
43
45
  nil
44
46
  end
45
47
 
46
- def respond_to_missing?(_name, _include_private = false)
47
- true
48
+ def respond_to_missing?(name, include_private = false)
49
+ ___key?(name) || ___key?(name.to_s.chomp("?")) || super
48
50
  end
49
51
  end
50
52
  LooseStruct = FlexStruct
@@ -31,7 +31,7 @@ module ResourceStruct
31
31
  end
32
32
 
33
33
  def respond_to_missing?(name, include_private = false)
34
- ___key?(name) || name.end_with?("?") || super
34
+ ___key?(name) || ___key?(name.to_s.chomp("?")) || super
35
35
  end
36
36
  end
37
37
  FirmStruct = StrictStruct
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ResourceStruct
4
- VERSION = "0.3.2"
4
+ VERSION = "0.3.3"
5
5
  end
metadata CHANGED
@@ -1,11 +1,11 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resource-struct
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Riedler
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
11
  date: 2022-01-05 00:00:00.000000000 Z
@@ -41,7 +41,7 @@ metadata:
41
41
  homepage_uri: https://github.com/AlexRiedler/resource-struct
42
42
  source_code_uri: https://github.com/AlexRiedler/resource-struct
43
43
  changelog_uri: https://raw.githubusercontent.com/AlexRiedler/resource-struct/master/CHANGELOG.md
44
- post_install_message:
44
+ post_install_message:
45
45
  rdoc_options: []
46
46
  require_paths:
47
47
  - lib
@@ -56,8 +56,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
56
56
  - !ruby/object:Gem::Version
57
57
  version: '0'
58
58
  requirements: []
59
- rubygems_version: 3.1.6
60
- signing_key:
59
+ rubygems_version: 3.0.3
60
+ signing_key:
61
61
  specification_version: 4
62
62
  summary: Ruby structs for resource responses
63
63
  test_files: []