async-service 0.6.1 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/async/service/configuration.rb +9 -2
- data/lib/async/service/controller.rb +4 -0
- data/lib/async/service/environment.rb +23 -5
- data/lib/async/service/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9712448ebd0e8279fcc9820181ba9f72eb4799fc9735118fbbaea548b1650ff4
|
4
|
+
data.tar.gz: c71431b601e6fc9d5f1635a47a865b028fc7bb6c6c893c4496fe46dd73c485bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cfb98e0d17511c3b917bfd98ed278f79f643e94cfaf2f93002076974ca2ffa0621fa8dde402d845eb5c49ba63f6d96ce23e9f864dccd233c1e17c68c610a1c5b
|
7
|
+
data.tar.gz: bcc17aa016c6b972f4155071ec819f2b54dae4c925c5bcad6a8132651dd6cc6a8f9bcbecc950a148190be7011ed80f12d2a0596958db60e78720a1f116fccaf4
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
@@ -5,6 +5,7 @@
|
|
5
5
|
|
6
6
|
require_relative 'loader'
|
7
7
|
require_relative 'generic'
|
8
|
+
require_relative 'controller'
|
8
9
|
|
9
10
|
module Async
|
10
11
|
module Service
|
@@ -33,14 +34,20 @@ module Async
|
|
33
34
|
@environments.empty?
|
34
35
|
end
|
35
36
|
|
36
|
-
def services
|
37
|
-
return to_enum(:services) unless block_given?
|
37
|
+
def services(implementing: nil)
|
38
|
+
return to_enum(:services, implementing: implementing) unless block_given?
|
38
39
|
|
39
40
|
@environments.each do |environment|
|
41
|
+
next if implementing and environment.implements?(implementing)
|
42
|
+
|
40
43
|
yield Generic.wrap(environment)
|
41
44
|
end
|
42
45
|
end
|
43
46
|
|
47
|
+
def controller(**options)
|
48
|
+
Controller.new(self.services(**options).to_a)
|
49
|
+
end
|
50
|
+
|
44
51
|
# Add the environment to the configuration.
|
45
52
|
def add(environment)
|
46
53
|
@environments << environment
|
@@ -59,6 +59,12 @@ module Async
|
|
59
59
|
@parent = parent
|
60
60
|
end
|
61
61
|
|
62
|
+
# @attribute [Module] The facet module.
|
63
|
+
attr :facet
|
64
|
+
|
65
|
+
# @attribute [Environment | Nil] The parent environment, if any.
|
66
|
+
attr :parent
|
67
|
+
|
62
68
|
def included(target)
|
63
69
|
@parent&.included(target)
|
64
70
|
target.include(@facet)
|
@@ -68,6 +74,10 @@ module Async
|
|
68
74
|
return self.class.new(Builder.for(...), self)
|
69
75
|
end
|
70
76
|
|
77
|
+
def implements?(interface)
|
78
|
+
@facet <= interface
|
79
|
+
end
|
80
|
+
|
71
81
|
# An evaluator is lazy read-only view of an environment. It memoizes all method calls.
|
72
82
|
class Evaluator
|
73
83
|
def self.wrap(environment)
|
@@ -78,16 +88,24 @@ module Async
|
|
78
88
|
|
79
89
|
evaluator.include(facet)
|
80
90
|
|
91
|
+
keys = []
|
92
|
+
|
81
93
|
# Memoize all instance methods:
|
82
94
|
facet.instance_methods.each do |name|
|
83
|
-
|
84
|
-
|
95
|
+
instance_method = facet.instance_method(name)
|
96
|
+
|
97
|
+
# Only memoize methods with no arguments:
|
98
|
+
if instance_method.arity == 0
|
99
|
+
keys << name
|
100
|
+
|
101
|
+
evaluator.define_method(name) do
|
102
|
+
@cache[name] ||= super()
|
103
|
+
end
|
85
104
|
end
|
86
105
|
end
|
87
106
|
|
88
|
-
|
89
|
-
|
90
|
-
end
|
107
|
+
# This lists all zero-argument methods:
|
108
|
+
evaluator.define_method(:keys) {keys}
|
91
109
|
|
92
110
|
return evaluator.new
|
93
111
|
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.
|
4
|
+
version: 0.8.0
|
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-
|
40
|
+
date: 2024-03-22 00:00:00.000000000 Z
|
41
41
|
dependencies:
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: async
|
metadata.gz.sig
CHANGED
Binary file
|