sober_swag 0.11.0 → 0.12.0

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: c07baa6165df700b23c0f8a0c9bd1a1dcb841d79b07995479b0c1e19a69928d7
4
- data.tar.gz: 523a0eabeb954497f531485962b0f058dc9a32ec398df899162c66e5d985d01e
3
+ metadata.gz: fa0e0e510ec9344738f12f01098f1d34557ac41c83dc966b4368b1407496b868
4
+ data.tar.gz: 50f62bed3de241407e3d16caaae632dc8af21781477ac7e212a60af71780c932
5
5
  SHA512:
6
- metadata.gz: 0ccf5c1f96d1647e42e082bfdd05c0a0ba3ff9d6d0bbe9139f9349bd17c917e854057af26a073c84aeeb54ac065c8c9f297d99d8063a0bccf032f77217c900bd
7
- data.tar.gz: f01787f76223c896154312b43862ac1276154715c9b8234a761c84dc046a1f5ab7f82e387c821805bf2f3b22ed99452bd834336dfdfc8f15350345efcc575de8
6
+ metadata.gz: 04ad84a03ee992677593aeea1342ddbb1fb693d7f67ae6c9e3b31b8d5050aeda86d71f65390d906ade4d30e458cdb7717d3ef02d93f3e966a92e4fac63240e8e
7
+ data.tar.gz: 535711fae0cc27c5122f5873cf64901e571631d9d87ecc04d44420deb99ff173bf83c0b36cdd34ce44aa6a697cec643098a8784be2487c2f9619ea78b52b2754
@@ -13,9 +13,16 @@ module SoberSwag
13
13
  # The name to use for this type in external documentation.
14
14
  def identifier(arg = nil)
15
15
  @identifier = arg if arg
16
+
16
17
  @identifier || name.to_s.gsub('::', '.')
17
18
  end
18
19
 
20
+ def meta(*args)
21
+ super(*args).tap do |result|
22
+ result.identifier(identifier) if result.is_a?(Class) # pass on identifier
23
+ end
24
+ end
25
+
19
26
  def primitive(sym)
20
27
  SoberSwag::Types.const_get(sym)
21
28
  end
@@ -20,20 +20,21 @@ module SoberSwag
20
20
  self.class.new(base, metadata.merge(hash))
21
21
  end
22
22
 
23
- ##
24
- # Delegates to `base`, adds metadata, pumbs identifiers
25
23
  def lazy_type
26
- @base.lazy_type.meta(**metadata).tap { |t| t.identifier(@base.identifier) }
24
+ @lazy_type ||= @base.lazy_type.meta(**metadata)
27
25
  end
28
26
 
29
- ##
30
- # Delegates to `base`, adds metadata, plumbs identifiers
31
27
  def type
32
- @base.type.meta(**metadata).tap { |t| t.identifier(@base.identifier) }
28
+ @type ||= @base.type.meta(**metadata)
33
29
  end
34
30
 
35
31
  def finalize_lazy_type!
36
32
  @base.finalize_lazy_type!
33
+ # Using .meta on dry-struct returns a *new type* that wraps the old one.
34
+ # As such, we need to be a bit clever about when we tack on the identifier
35
+ # for this type.
36
+ lazy_type.identifier(@base.lazy_type.identifier)
37
+ type.identifier(@base.type.identifier)
37
38
  end
38
39
 
39
40
  def lazy_type?
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SoberSwag
4
- VERSION = '0.11.0'
4
+ VERSION = '0.12.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sober_swag
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anthony Super