atacama 0.1.7 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2d78853c9e718c4ea9ff6ea4fbc8e729cd2f48cf
4
- data.tar.gz: addda9f05177a741fc8d2dd36d465646e37249c0
3
+ metadata.gz: 6c60dffa1549a8ad42d49c0d5a54aeeb5985c553
4
+ data.tar.gz: 9bc7644e038ce25f28436b0402712171093933b7
5
5
  SHA512:
6
- metadata.gz: 88ca8a4083003137ca041c1b985cbe4f8046d5777c1b45fa75994fe7f435c5fddc9b8eb83344789bc6e0a10f925ca348e01dff8ae9c9361c560863f2d7a1d317
7
- data.tar.gz: 1166397fca1f7348584534140b3edc31418384cb4cc9c4e3d7e735608f6000eab5028524e585b7c5a0db1dea90656b1d4041bf258e94f071d64820a855e8a914
6
+ metadata.gz: f869b06dfe02bca18b86611aa5613a96e3393d2b9c4013400b91b38a52ca5a7a9436bbf1ad79bdd9fca75e1450d096835949eb6375de109576300705710faa3b
7
+ data.tar.gz: 3f0bd303fb8a123eb0733a91352e58523e660d9c9dad2013cb29425a79e813bcafa5f4380d36cfa9d0023995d5141ad1499731f9525f131702bacb0d07a32d57
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- atacama (0.1.7)
4
+ atacama (0.1.8)
5
5
  dry-types (~> 0.13.2)
6
6
 
7
7
  GEM
@@ -9,10 +9,16 @@ module Atacama
9
9
  ReturnTypeMismatchError = Class.new(StandardError)
10
10
  ResultTypeMismatchError = Class.new(StandardError)
11
11
 
12
+ # Execute a type check, catch and yield if theres an error.
13
+ #
14
+ # @yields [Exception] the caught type error
15
+ #
16
+ # @param type [Dry::Types?] type to check
17
+ # @param value [Object] object to execute with
12
18
  def self.check(type, value)
13
19
  type && type[value]
14
20
  nil
15
- rescue Dry::Types::ConstraintError => e
16
- yield e
21
+ rescue Dry::Types::ConstraintError => exception
22
+ yield exception
17
23
  end
18
24
  end
@@ -9,13 +9,5 @@ module Atacama
9
9
  @name = name
10
10
  @type = type
11
11
  end
12
-
13
- # Determine the validity of a value for an optionally given type. Raises a
14
- # type error on failure.
15
- #
16
- # @raise [Dry::Types::ConstraintError]
17
- def validate!(value)
18
- type[value] && nil unless type.nil?
19
- end
20
12
  end
21
13
  end
@@ -25,9 +25,7 @@ module Atacama
25
25
 
26
26
  def detect_invalid_types!
27
27
  options.each do |key, parameter|
28
- begin
29
- parameter.validate! context[key]
30
- rescue Dry::Types::ConstraintError => e
28
+ Atacama.check(parameter.type, context[key]) do |e|
31
29
  raise OptionTypeMismatchError, %(#{klass} option :#{key} invalid: #{e.message})
32
30
  end
33
31
  end
@@ -1,3 +1,3 @@
1
1
  module Atacama
2
- VERSION = '0.1.7'.freeze
2
+ VERSION = '0.1.8'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: atacama
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tyler Johnston
@@ -91,7 +91,6 @@ files:
91
91
  - lib/atacama/step.rb
92
92
  - lib/atacama/transaction.rb
93
93
  - lib/atacama/transaction/definition.rb
94
- - lib/atacama/transaction/halt_execution.rb
95
94
  - lib/atacama/types.rb
96
95
  - lib/atacama/values.rb
97
96
  - lib/atacama/version.rb
@@ -1,12 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Atacama
4
- class HaltExecution < StandardError
5
- attr_reader :value
6
-
7
- def initialize(value)
8
- super('Execution was halted and yielding a value with #value')
9
- @value = value
10
- end
11
- end
12
- end