low_type 0.8.6 → 0.8.7

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: ef26c686d314eec78cc49419d8f13d502d0a167f5b059961805754d38fd79a78
4
- data.tar.gz: df781758ab9e3bb9a5d9a7c2119cd6dd3d080ec2cc123cf78aa9a90b75b660fd
3
+ metadata.gz: 94ec8cf1ae80a7540248e9a0a97e2e9bbc99fb81724f9a89e3d35de0ccd3dfaa
4
+ data.tar.gz: f1bf339671b5d17ec247814a08ea665aca64df51f404f625dff5d6bf77cf7c2e
5
5
  SHA512:
6
- metadata.gz: 941cd854ce780919c11335896b727eb8e4084e42d4c75ca2c4e563507d1ba7c2a580c19e8056e2cb45c093b76387921df1eeba71f82e4a176e57478d73c492e2
7
- data.tar.gz: d47aa4998fd2154703359e382564321ad4dcd1cf6107990d5a7ec5b18634e8b1440d77fab5e0b165bfd6640ac114a771ed5e9a7dadcac284cc6941a43aaf0de4
6
+ metadata.gz: 7a6ff0fa4038f53cd1650f27e7523ec2e0c0ac75c66190d62d976dbaded7887c2dc1900cb514709255af87f1c01545eb7c0748c100cd8133ea947c3d03f0c785
7
+ data.tar.gz: 141e666816a66e0446b0d9559d288dc24b7e838c200537fbfd5b18297533f8812517e37e29d3bcf7388efbef82fffb1aa90a6407037c4803db8bc6a1b26645f8
@@ -51,9 +51,7 @@ module LowType
51
51
  proxy.type_expression.types.each do |type|
52
52
  value = SinatraAdapter.reconstruct_return_value(type:, response:)
53
53
  unless proxy.type_expression.validate(value:, proxy:)
54
- status(500)
55
- body(proxy.error_message(value: value.inspect))
56
- break
54
+ halt 500, {}, proxy.error_message(value: value.inspect)
57
55
  end
58
56
  end
59
57
  end
@@ -72,12 +70,11 @@ module LowType
72
70
  HTML => -> (response) { response.body.first },
73
71
  JSON => -> (response) { response.body.first },
74
72
 
75
- # TODO: Should these be Enumerable[T] instead? How would we match a Module of a class in a hash key?
76
- # NOTE: These keys represent types, not type expressions.
77
- # A type lives inside a type expression and is actually an instance representing that type.
78
- [String] => -> (response) { response.body },
79
- [Integer, String] => -> (response) { [response.status, *response.body] },
80
- [Integer, Hash, String] => -> (response) { [response.status, response.headers, *response.body] },
73
+ [String] => -> (response) { response.body }, # Body is stored internally as an array.
74
+ [Integer, String] => -> (response) { [response.status, response.body.first] },
75
+ [Integer, Hash, String] => -> (response) { [response.status, response.headers, response.body.first] },
76
+
77
+ # TODO: Represent Enumerable[T]. How would we match a Module of a class in a hash key?
81
78
  }
82
79
 
83
80
  raise AllowedTypeError, 'Did you mean "Response.finish"?' if type.to_s == 'Response'
@@ -7,6 +7,7 @@ module LowType
7
7
  attr_reader :types, :default_value
8
8
 
9
9
  def initialize(type: nil, default_value: :LOW_TYPE_UNDEFINED)
10
+ # Types can be instance representations of a structure.
10
11
  @types = []
11
12
  @types << type unless type.nil?
12
13
  @default_value = default_value
data/lib/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LowType
4
- VERSION = '0.8.6'
4
+ VERSION = '0.8.7'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: low_type
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.6
4
+ version: 0.8.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - maedi