low_type 1.1.10 → 1.1.11

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: 54e1e267e4ef98dc2364738a169dee20cb6364d9cb597c8f7c46084309b2296f
4
- data.tar.gz: 1c1b44d5b7ba03b955d039bf62a7898897d2d04230dc89ff58df055de719d37d
3
+ metadata.gz: c82a177983dc14e1e81ca0a1c69116d0c93f833cfab0c1b5bbe33abd1af330f9
4
+ data.tar.gz: 9313d43a504a3e9fd35f2e26b0e45f188507ae3d6565121569a22314af3e6a2d
5
5
  SHA512:
6
- metadata.gz: 39b512c4ff8c250659bdce0bb1be51c5f3e46e7a8ac30fa607deabdf9c933b7459bb78542211aafebf483dff3ecd8600ebb589dd4b91fb0d410c4dd9206e74fb
7
- data.tar.gz: 0d4840867f0454b51b82f64807b691c4a4e4ac1380f5de113862ca8964f12fd18a62e0accaa51fad1105b94be403659ed5a80f486b4fc3ad4a1cddaf72abbf59
6
+ metadata.gz: 02b10b638da5368d50a962644bf4bf4f1381b4ae705ca0aaa54fd207e70d49c3098d4cad3f4a42d0843ea0a7580cf8ea6c6992d105965d5f4165427955fbeb01
7
+ data.tar.gz: 2fe096a5eb05a18abe85820d9a387758d2484a916e8434275256b3abc17772230489152f34245c7577ad2b721c2237b5e6c098759205cfbbb9328e2814af9b43
@@ -61,6 +61,7 @@ module Low
61
61
 
62
62
  value = positional ? args[param_proxy.position] : kwargs[param_proxy.name]
63
63
  value = param_proxy.expression.default_value if value.nil? && !param_proxy.expression.required?
64
+
64
65
  param_proxy.expression.validate!(value:, proxy: param_proxy)
65
66
  value = value.value if value.is_a?(ValueExpression)
66
67
 
@@ -11,11 +11,12 @@ module Low
11
11
  last_caller = caller_locations(1, 1).first
12
12
 
13
13
  file_path = last_caller.path
14
- start_line = last_caller.lineno
15
14
  scope = "#{self}##{name}"
16
15
 
17
16
  expression = cast_type_expression(exp)
18
- proxy = ::Lowkey::ReturnProxy.new(file_path:, start_line:, scope:, name:, expression:)
17
+ # Source usually defined on file load with access to lines in a source file, but type accessors are defined on class load.
18
+ source = ::Lowkey::Source.new(file_path:, scope:, lines: [], start_line: last_caller.lineno, end_line: last_caller.lineno)
19
+ proxy = ::Lowkey::ReturnProxy.new(name:, source:, expression:)
19
20
 
20
21
  define_method(name) do
21
22
  value = instance_variable_get("@#{name}")
@@ -30,11 +31,12 @@ module Low
30
31
  last_caller = caller_locations(1, 1).first
31
32
 
32
33
  file_path = last_caller.path
33
- start_line = last_caller.lineno
34
34
  scope = "#{self}##{name}"
35
35
 
36
36
  expression = cast_type_expression(expression)
37
- proxy = ::Lowkey::ParamProxy.new(file_path:, start_line:, scope:, name:, type: :key_req, expression:)
37
+ # Source usually defined on file load with access to lines in a source file, but type accessors are defined on class load.
38
+ source = ::Lowkey::Source.new(file_path:, scope:, lines: [], start_line: last_caller.lineno, end_line: last_caller.lineno)
39
+ proxy = ::Lowkey::ParamProxy.new(name:, source:, type: :pos_req, position: nil, expression:)
38
40
 
39
41
  define_method("#{name}=") do |value|
40
42
  expression.validate!(value:, proxy:)
data/lib/low_type.rb CHANGED
@@ -34,7 +34,7 @@ module LowType
34
34
  # We do as much as possible on class load rather than on object instantiation to be thread-safe and efficient.
35
35
  def self.included(klass)
36
36
  file_path = Low::FileQuery.file_path(klass:)
37
- file_proxy = Lowkey.load(file_path:)
37
+ file_proxy = Lowkey.load(file_path)
38
38
  class_proxy = file_proxy[klass.name]
39
39
 
40
40
  Low::Evaluator.evaluate(method_proxies: class_proxy.keyed_methods)
data/lib/types/status.rb CHANGED
@@ -5,10 +5,15 @@ require_relative 'error_types'
5
5
 
6
6
  module Low
7
7
  module Types
8
- # Status is an Integer for type checking, but an instance of StatusCode for advanced functionality.
8
+ # Status is an Integer for basic type checking...
9
9
  class Status < Integer
10
10
  extend ComplexType
11
11
 
12
+ # ...but becomes an instance of StatusCode when called with "Status[:code]" for advanced type checking (status + code).
13
+ def self.[](status_code)
14
+ @status_code = StatusCode.new(status_code)
15
+ end
16
+
12
17
  class StatusCode
13
18
  attr_reader :status_code
14
19
 
@@ -44,10 +49,6 @@ module Low
44
49
  [self.class, @status_code].hash
45
50
  end
46
51
  end
47
-
48
- def self.[](status_code)
49
- @status_code = StatusCode.new(status_code)
50
- end
51
52
  end
52
53
  end
53
54
  end
data/lib/version.rb CHANGED
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Low
4
4
  module Type
5
- VERSION = '1.1.10'
5
+ VERSION = '1.1.11'
6
6
  end
7
7
  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: 1.1.10
4
+ version: 1.1.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - maedi
@@ -29,14 +29,14 @@ dependencies:
29
29
  requirements:
30
30
  - - "~>"
31
31
  - !ruby/object:Gem::Version
32
- version: '0.3'
32
+ version: '0.4'
33
33
  type: :runtime
34
34
  prerelease: false
35
35
  version_requirements: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: '0.3'
39
+ version: '0.4'
40
40
  description: An elegant and simple way to define types in Ruby, only when you need
41
41
  them.
42
42
  email: