hub_kernel-interface 0.1.0 → 0.3.0
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/README.md +15 -0
- data/lib/hub_kernel/interface/version.rb +1 -1
- data/lib/hub_kernel/interface.rb +12 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 37c5ea275a8aaacc15d056ff35580688737ef2210a22e22846276404cf7b052b
|
|
4
|
+
data.tar.gz: 8ca84328489427f9d5616ad4d93b620219bbb6bc550a5ec63ac0f7e54ec3e569
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ef4ee5d46d58f791c724fbaa24402cc3db861c05b1193a4a13d60a413aae415bdab29400cbf10c4fe5ae7580be660c6e3740012ad5c9cbe0a93733674f1b2c32
|
|
7
|
+
data.tar.gz: 2410f02d15351de8a053741bd66c14a162d34ce4f60a910acaa13f2002cc63742716f2029ed02ff042d4aee2323123cb9fc9dff2ec1f07498fee4f9c166c634c
|
data/README.md
CHANGED
|
@@ -40,6 +40,21 @@ for a missing person, account or required value. A hub refuses with `HubKernel::
|
|
|
40
40
|
reason a person can read. A call made while the permission check or the account scope is unset
|
|
41
41
|
raises `HubKernel::UnwiredPortError`.
|
|
42
42
|
|
|
43
|
+
The host names the hubs every interface serves, once. A hub listed alone is served at its
|
|
44
|
+
module name in snake case, and a hub listed as a one-pair hash is served only at the name
|
|
45
|
+
given. An interface gem finds the hub served at a name, or `nil` when none is:
|
|
46
|
+
|
|
47
|
+
```ruby
|
|
48
|
+
HubKernel::Interface.hubs = [ Supplies, { "money" => Billing::Ledger } ]
|
|
49
|
+
|
|
50
|
+
HubKernel::Interface.find("supplies") # => Supplies
|
|
51
|
+
HubKernel::Interface.find("money") # => Billing::Ledger
|
|
52
|
+
HubKernel::Interface.served # => { "supplies" => Supplies, "money" => Billing::Ledger }
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
The permission check is still asked about a hub served under a chosen name by its own name,
|
|
56
|
+
such as `ledger:record_spend`.
|
|
57
|
+
|
|
43
58
|
`Supplies.exposure_problems` names each exposed method the hub has no method for, or lists
|
|
44
59
|
with values it does not take. `HubKernel::Interface::ExposingHubs.list` holds every hub that
|
|
45
60
|
declares an exposed method.
|
data/lib/hub_kernel/interface.rb
CHANGED
|
@@ -1,2 +1,14 @@
|
|
|
1
1
|
require "hub_kernel/interface/version"
|
|
2
2
|
require "hub_kernel/exposes"
|
|
3
|
+
|
|
4
|
+
module HubKernel
|
|
5
|
+
module Interface
|
|
6
|
+
singleton_class.attr_writer :hubs
|
|
7
|
+
|
|
8
|
+
def self.hubs = @hubs ||= []
|
|
9
|
+
|
|
10
|
+
def self.find(name) = served[name]
|
|
11
|
+
|
|
12
|
+
def self.served = hubs.flat_map { |entry| entry.is_a?(Hash) ? entry.to_a : [ [ entry.name.demodulize.underscore, entry ] ] }.to_h
|
|
13
|
+
end
|
|
14
|
+
end
|