atacama 0.1.4 → 0.1.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
  SHA1:
3
- metadata.gz: 504860bd1cc4b868e1299d7e43ea02a29efdf385
4
- data.tar.gz: 56b29c7f192e6513fb1b039397ea55fe3cd54d7c
3
+ metadata.gz: 962e473a80996947e194283a65b1a31ca998d448
4
+ data.tar.gz: 7df566c68e5e900c7f05fca2743c6c945d410e16
5
5
  SHA512:
6
- metadata.gz: 38ae0a44fda886f8ce080f0e6734863094c7d34ed5d3a54497741602328012b5f6949f0c1852c043009e0909216428fd0212fb8f4747250e8afdea33215b7fbc
7
- data.tar.gz: 2116d76499411e0bcb3183ebd83338f37e05f48548bbbfc8545eb092df6746e9329e0f4334b6437f1d85839cd1f7c62632e4fa2a30b3da709363c0adc11a3834
6
+ metadata.gz: b13dfd1450db5916e15e44baac9d38b1e64659cfefc8098d2a92628b6b2f10e89eae2303027ebc048898dfa8f39232691d2a741cc8835fe8d3c5dbdf7d08ca34
7
+ data.tar.gz: a8d26a7ca84b95564092d282839024411bf2cd97d9943288c22f02f67c7000cf8d379a828fef81f08e62a99337a60294c97516b55df29993c8db0b35a132ea65
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- atacama (0.1.4)
4
+ atacama (0.1.5)
5
5
  dry-types (~> 0.13.2)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -30,6 +30,7 @@ The basic object is `Contract`. It enforces type contracts by utilizing `dry-typ
30
30
  ```
31
31
  class UserFetcher < Atacama::Contract
32
32
  option :id, Types::Strict::Number.gt(0)
33
+ returns Types.Instance(User)
33
34
 
34
35
  def call
35
36
  User.find(id)
@@ -45,6 +46,7 @@ of changes to execute.
45
46
  ```
46
47
  class UserFetcher < Atacama::Step
47
48
  option :id, type: Types::Strict::Number.gt(0)
49
+ returns Types.Option(model: Types.Instance(User))
48
50
 
49
51
  def call
50
52
  Option(model: User.find(id))
@@ -60,9 +62,11 @@ class Duration < Atacama::Step
60
62
  end
61
63
 
62
64
  class UpdateUser < Atacama::Transformer
63
- option :model, type: Types::Instance(User)
65
+ option :model, type: Types.Instance(User)
64
66
  option :attributes, type: Types::Strict::Hash
65
67
 
68
+ returns_option :model, Types.Instance(User)
69
+
66
70
  step :duration, with: Duration do
67
71
  step :find, with: UserFetcher
68
72
  step :save
@@ -1,33 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'atacama/types'
3
4
  require 'atacama/contract/parameter'
4
5
  require 'atacama/contract/validator'
5
6
  require 'atacama/contract/context'
6
7
 
7
8
  module Atacama
8
- # The type namespace to interact with DRY::Types
9
- module Types
10
- include Dry::Types.module
11
- Boolean = Types::True | Types::False
12
-
13
- def self.Option(**map)
14
- Instance(Values::Option).constructor do |options|
15
- map.each do |key, type|
16
- type[options.value[key]]
17
- end
18
-
19
- options
20
- end
21
- end
22
-
23
- def self.Return(type)
24
- Instance(Values::Return).constructor do |options|
25
- type[options.value]
26
- options
27
- end
28
- end
29
- end
30
-
31
9
  # This class enables a DSL for creating a contract for the initializer
32
10
  class Contract
33
11
  RESERVED_KEYS = %i[call initialize context].freeze
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Atacama
4
+ # The type namespace to interact with DRY::Types
5
+ module Types
6
+ include Dry::Types.module
7
+ Boolean = Types::True | Types::False
8
+
9
+ def self.Option(**map)
10
+ Instance(Values::Option).constructor do |options|
11
+ if options.is_a? Values::Option
12
+ map.each { |key, type| type[options.value[key]] }
13
+ end
14
+
15
+ options
16
+ end
17
+ end
18
+
19
+ def self.Return(type)
20
+ Instance(Values::Return).constructor do |options|
21
+ type[options.value] if options.is_a? Values::Return
22
+ options
23
+ end
24
+ end
25
+ end
26
+ end
@@ -1,3 +1,3 @@
1
1
  module Atacama
2
- VERSION = '0.1.4'.freeze
2
+ VERSION = '0.1.5'.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.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tyler Johnston
@@ -91,6 +91,7 @@ files:
91
91
  - lib/atacama/transaction.rb
92
92
  - lib/atacama/transaction/definition.rb
93
93
  - lib/atacama/transaction/halt_execution.rb
94
+ - lib/atacama/types.rb
94
95
  - lib/atacama/values.rb
95
96
  - lib/atacama/version.rb
96
97
  homepage: https://github.com/fulcrumapp/atacama