atacama 0.1.2 → 0.1.3
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 +4 -4
- data/Gemfile.lock +2 -2
- data/lib/atacama/contract/context.rb +2 -3
- data/lib/atacama/contract.rb +20 -3
- data/lib/atacama/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e1dd85acd949dc1261176c76b76e38add8ab8772
|
4
|
+
data.tar.gz: 3d0006d2e584122ca3534748f620e0a335acad5b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f3938b99da71d5b9994c8993b01b42847c9e09dff9523b7d9650a7abe977d91aff71a60169378d9207ad65e1a8eb1cd51c0846b33bda4d4724396d61815115b2
|
7
|
+
data.tar.gz: 1bd1146d793105404d1ea9e5f27b7c310c695ac378babb683d1cae83dace8af5a0ad1b017fc743c0ba1fd4f3e3d2011c40f1bb9d0684d3f24d29fe2c4c146782
|
data/Gemfile.lock
CHANGED
data/lib/atacama/contract.rb
CHANGED
@@ -21,6 +21,14 @@ module Atacama
|
|
21
21
|
ContextInterface = Types::Strict::Hash | Types.Instance(Context)
|
22
22
|
|
23
23
|
class << self
|
24
|
+
def injected=(hash)
|
25
|
+
@injected = Types::Strict::Hash[hash]
|
26
|
+
end
|
27
|
+
|
28
|
+
def injected
|
29
|
+
@injected || {}
|
30
|
+
end
|
31
|
+
|
24
32
|
def options
|
25
33
|
@options ||= {}
|
26
34
|
end
|
@@ -28,8 +36,7 @@ module Atacama
|
|
28
36
|
# Define an initializer value.
|
29
37
|
# @param [Symbol] name of the argument
|
30
38
|
def option(name, **kwargs)
|
31
|
-
NameInterface[name]
|
32
|
-
options[name] = Parameter.new(name: name, **kwargs)
|
39
|
+
options[NameInterface[name]] = Parameter.new(name: name, **kwargs)
|
33
40
|
|
34
41
|
define_method(name) { @context[name] }
|
35
42
|
define_method("#{name}?") { !!@context[name] }
|
@@ -38,13 +45,23 @@ module Atacama
|
|
38
45
|
def call(context = {})
|
39
46
|
new(context: context).call
|
40
47
|
end
|
48
|
+
|
49
|
+
def inject(injected)
|
50
|
+
Class.new(self) do
|
51
|
+
self.injected = injected
|
52
|
+
end
|
53
|
+
end
|
41
54
|
end
|
42
55
|
|
43
56
|
attr_reader :context
|
44
57
|
|
45
58
|
def initialize(context: {}, **)
|
46
59
|
ContextInterface[context] # Validate the type
|
47
|
-
|
60
|
+
|
61
|
+
@context = Context.new(self.class.injected).tap do |ctx|
|
62
|
+
ctx.merge!(context.is_a?(Context) ? context.to_h : context)
|
63
|
+
end
|
64
|
+
|
48
65
|
Validator.call(options: self.class.options, context: @context)
|
49
66
|
end
|
50
67
|
|
data/lib/atacama/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: atacama
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tyler Johnston
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-11-
|
11
|
+
date: 2018-11-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-types
|