purple-client 0.1.9.2 → 0.1.9.3

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: 502680751797b4799c3e5f5d19fa0e954bd5a27eaf1b4b755766a388e6c3f70a
4
- data.tar.gz: 4640aa3ce4043533a8d34869922b2bad44f7e398575466d6e00d757710dd57b4
3
+ metadata.gz: 381595d6be33f7e1f3c7a838182db63d5f157ba3978fa70f99b78c75391a9c06
4
+ data.tar.gz: 48aa5d67fd40fd4d8c8b1bf482e4e493d69f77dd8d9c8fe7011382a74437806f
5
5
  SHA512:
6
- metadata.gz: f15b0a14ce71d8d510a21580cc7e168537b49f268f8c580f02befe92b764f1fb1ccc844cb825db5f6e42ed2dbc0647c368252394b32efa70cf3565bdecbc45ec
7
- data.tar.gz: 24f8df9b9b90192a697ecf94da2f7517bff6e72e0ae16dc4055af1eef9eda5f5aab55083a1aaa24f949cab90e9de90769fa69469cd7a2ce66d8aedbaeff7d9df
6
+ metadata.gz: '084bbb42e3790b1e291c5f95dc5928ec23acb1d6df597b8471e7f6effb279c08eff9f99281f046bc9e84658ec03cd39c943d8aa4a510fa79397afe0e4240550e'
7
+ data.tar.gz: cd0c4805e785f1cc92087b12a902fb23c78c90e15c540d52a4cedf78990a9c3cedd2ebfaf6d5583617e6a7c71b40db0fdfc208e8147e1b1eb0f0aad4a1b47ddc
@@ -82,9 +82,11 @@ class Purple::Responses::Body
82
82
  next if value[:optional]
83
83
  next if value[:allow_blank] && object[key].blank?
84
84
 
85
- raise BodyStructureMismatchError.new(key, value[:type], object[key], object) if object[key].is_a?(Array)
86
-
87
- check_type!(object, key, value[:type])
85
+ if object[key].is_a?(Array)
86
+ check_array!(object, key, value[:type].first, substructure[key][:type].first)
87
+ else
88
+ check_type!(object, key, value[:type])
89
+ end
88
90
  else
89
91
  next if object[key].nil?
90
92
 
@@ -96,22 +98,7 @@ class Purple::Responses::Body
96
98
  "Expected a non-nil array for '#{key}' in response body.\n\nExpected response structure: #{substructure}.\n\nUse '#{key}: { type: #{value}, allow_blank: true }' if this field can be nil, blank or empty."
97
99
  end
98
100
 
99
- type = value.first
100
-
101
- if type.is_a?(Symbol)
102
- raise "Body structure definition error in key '#{key}' of structure #{substructure}."
103
- end
104
-
105
- object[key].each_with_index do |item, index|
106
- if type.is_a?(Class)
107
- unless item.is_a?(type)
108
- raise BodyStructureMismatchError.new(key, type, item, object),
109
- "Expected item at #{index} index of '#{key}' to be of type '#{value[index]}', but got '#{item.class}' with value '#{item}'."
110
- end
111
- else
112
- check_structure!(item, type)
113
- end
114
- end
101
+ check_array!(object, key, value.first, substructure)
115
102
  else
116
103
  if object.nil?
117
104
  raise BodyStructureMismatchError.new(key, value, nil, object),
@@ -123,6 +110,23 @@ class Purple::Responses::Body
123
110
  end
124
111
  end
125
112
 
113
+ def check_array!(object, key, type, substructure)
114
+ if type.is_a?(Symbol)
115
+ raise "Body structure definition error in key '#{key}' of structure #{substructure}."
116
+ end
117
+
118
+ object[key].each_with_index do |item, index|
119
+ if type.is_a?(Class)
120
+ unless item.is_a?(type)
121
+ raise BodyStructureMismatchError.new(key, type, item, object),
122
+ "Expected item at #{index} index of '#{key}' to be of type '#{value[index]}', but got '#{item.class}' with value '#{item}'."
123
+ end
124
+ else
125
+ check_structure!(item, type)
126
+ end
127
+ end
128
+ end
129
+
126
130
  def check_type!(object, key, expected_type)
127
131
  return if key.in?([:optional, :allow_blank])
128
132
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Purple
4
- VERSION = "0.1.9.2"
4
+ VERSION = "0.1.9.3"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: purple-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9.2
4
+ version: 0.1.9.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Kalashnikov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-09-16 00:00:00.000000000 Z
11
+ date: 2025-09-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-initializer