datacaster 3.2.3 → 3.2.5

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: f2b45e5271b85a571b86bd83ff91494d68486b677a2f0cc0f03daeeb5e8d5307
4
- data.tar.gz: 7dafa54ec77eee489282217026a845059725a164e381525be695874bbb2cecc3
3
+ metadata.gz: 6e87035b2c58689f1682294141d8ef6dfe02c6054a810e7bcda3a22f2d934091
4
+ data.tar.gz: d6262e0130ef3f831731e9b0d6095a40fa7a19bfa9eecd5a0630c5eb8a3d9513
5
5
  SHA512:
6
- metadata.gz: 37337520c11d06b98d30e5afcb890b2a8b1bfdbc06f05d070fb8d3c3dc52c4adc9263a9f92a29c0cf92051f5b58c57833f9d1330a8f7cb7fe39a46c2fad694f9
7
- data.tar.gz: 4792f1c3000d5df28c865e5c8c365a87356e8241009b9a7cbe5e55544422c964749ba43e8d6004aba05585a18e1795967dc6c3a22f2e06a03ef87eca0dd4fced
6
+ metadata.gz: 6800f34a95b7e8baaad2d2f093f4c6be58e35904220339c2c8c5452fcea375b169224ebf49c699d965073cf9b3777ab00b91adf48184d539c2ff1616accde73f
7
+ data.tar.gz: b8f9fd1227da11c029af5af57fb336f7e10f29b763123517ed4e5fbae0b27ca9ff6a65367841684edc366066ad27c720d367a318578b09637bfa98680bfcb58c
@@ -47,7 +47,8 @@ module Datacaster
47
47
  when Hash
48
48
  cast_hash(result, schema)
49
49
  else
50
- raise "Expected hash or array when checking #{value.inspect}"
50
+ raise RuntimeError, "Expected hash or array inside result when checking #{result.inspect} " \
51
+ "(schema is #{schema.inspect})", caller
51
52
  end
52
53
  end
53
54
 
@@ -35,8 +35,20 @@ module Datacaster
35
35
  @should_check_stack[-1] = true
36
36
  end
37
37
 
38
+ # Notify current runtime that some child runtime has built schema,
39
+ # child runtime's schema is passed as the argument
38
40
  def checked_schema!(schema)
39
- @pointer_stack[-1].merge!(schema)
41
+ # Current runtime has marked its schema as checked unconditionally
42
+ return if @pointer_stack[-1] == true
43
+
44
+ # Child runtime marks its schema as checked unconditionally, so
45
+ # current runtime should do as well
46
+ if schema == true
47
+ @pointer_stack[-1] = true
48
+ # Child runtime's schema should be merged with current runtime's schema
49
+ else
50
+ @pointer_stack[-1].merge!(schema)
51
+ end
40
52
  end
41
53
 
42
54
  def ignore_checks!(&block)
@@ -63,11 +63,8 @@ module Datacaster
63
63
  result = check.with_runtime(runtime).(switch_result)
64
64
  next unless result.valid?
65
65
 
66
- if @pick_key.nil?
67
- return clause.with_runtime(runtime).(object)
68
- else
69
- return runtime.checked_key!(@pick_key) { clause.with_runtime(runtime).(object) }
70
- end
66
+ runtime.checked_key!(@pick_key) if !@pick_key.nil? && !@pick_key.is_a?(Array)
67
+ return clause.with_runtime(runtime).(object)
71
68
  end
72
69
 
73
70
  # all 'on'-s have failed
@@ -1,3 +1,3 @@
1
1
  module Datacaster
2
- VERSION = "3.2.3"
2
+ VERSION = "3.2.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: datacaster
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.3
4
+ version: 3.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eugene Zolotarev
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-02-06 00:00:00.000000000 Z
11
+ date: 2024-02-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel