async-service 0.5.1 → 0.6.1

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
  SHA256:
3
- metadata.gz: b44bdc3df0be460edd3c80eb2c720cac60a8468d07ff2a72e9319098d772e99d
4
- data.tar.gz: 39e6aafef8d74711a9136f44bede0266401d68d852c840f72c02d14bb6278c5c
3
+ metadata.gz: 2c5d89c7f841e6cbe16bad8337324981ef85f1da92d2a8b8acada2c12a51c91c
4
+ data.tar.gz: 0fe963d6d034ce7b2c0644405fd2044cbd6645c61514d3be3698fdf0a2a52f7c
5
5
  SHA512:
6
- metadata.gz: 9e866b56bc410daa6d203fdeccf141c0b85d13c27cc8af84c4953ff69e02b1b70fd52dd0e71179ad87802a2afeab60c66b5ce6572172fa8132ccb69c42480f10
7
- data.tar.gz: b11bf4b2759197f1a9ac3e07d0a9a2630172c1d86b13a1cc63990125bc894dd5fb39f166c896e5480de4d7ee6cc917c5469f3e67cae999c20510d4558b4aec61
6
+ metadata.gz: 86087e42a857958582c02812a59391378f6ba8a62beb49641a67d90db744c6007299926b5b0d41db0a13fc1cbf8fe498593a5e1c45e65f57fcd6e03ecdd4f4b6
7
+ data.tar.gz: 17b9d71be9c88bcbbb52dfb0f15a75bf914062c757cfd4b4fbef058d83c99ea664495c58de3d7f3c6758438bb9d52fcf027124bbe8d6ad3e187c121e790e8827
checksums.yaml.gz.sig CHANGED
Binary file
@@ -7,8 +7,10 @@ module Async
7
7
  module Service
8
8
  class Environment
9
9
  class Builder < BasicObject
10
- def self.wrap(hash, facet = ::Module.new)
11
- hash.each do |key, value|
10
+ def self.for(facet = ::Module.new, **values, &block)
11
+ builder = self.new(facet)
12
+
13
+ values.each do |key, value|
12
14
  if value.is_a?(::Proc)
13
15
  facet.define_method(key, &value)
14
16
  else
@@ -16,12 +18,6 @@ module Async
16
18
  end
17
19
  end
18
20
 
19
- return facet
20
- end
21
-
22
- def self.for(facet = ::Module.new, &block)
23
- builder = self.new(facet)
24
-
25
21
  builder.instance_exec(&block) if block_given?
26
22
 
27
23
  return facet
@@ -50,19 +46,15 @@ module Async
50
46
  end
51
47
  end
52
48
 
53
- def self.build(**values, &block)
54
- if values.any?
55
- environment = Environment.new(Builder.wrap(values))
56
- end
57
-
58
- if block_given?
59
- environment = Environment.new(Builder.for(&block), environment)
60
- end
61
-
62
- return environment
49
+ def self.build(...)
50
+ Environment.new(Builder.for(...))
63
51
  end
64
52
 
65
53
  def initialize(facet = ::Module.new, parent = nil)
54
+ unless facet.class == ::Module
55
+ raise ArgumentError, "Facet must be a module!"
56
+ end
57
+
66
58
  @facet = facet
67
59
  @parent = parent
68
60
  end
@@ -72,6 +64,10 @@ module Async
72
64
  target.include(@facet)
73
65
  end
74
66
 
67
+ def with(...)
68
+ return self.class.new(Builder.for(...), self)
69
+ end
70
+
75
71
  # An evaluator is lazy read-only view of an environment. It memoizes all method calls.
76
72
  class Evaluator
77
73
  def self.wrap(environment)
@@ -5,6 +5,6 @@
5
5
 
6
6
  module Async
7
7
  module Service
8
- VERSION = "0.5.1"
8
+ VERSION = "0.6.1"
9
9
  end
10
10
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: async-service
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
@@ -37,7 +37,7 @@ cert_chain:
37
37
  Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
38
38
  voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
39
39
  -----END CERTIFICATE-----
40
- date: 2024-03-11 00:00:00.000000000 Z
40
+ date: 2024-03-17 00:00:00.000000000 Z
41
41
  dependencies:
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: async
metadata.gz.sig CHANGED
Binary file