hub_kernel-interface 0.5.0 → 0.6.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 +7 -3
- data/lib/hub_kernel/exposes.rb +6 -0
- data/lib/hub_kernel/interface/call_reasons.rb +3 -2
- data/lib/hub_kernel/interface/version.rb +1 -1
- 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: 46efe9234db5355c30fb8e4860fb8183028c7d41fb5e4ca4172d5f939bf0aee8
|
|
4
|
+
data.tar.gz: a0108815b76bd611f424978603340d9c1901d8e5d0632e78f1482dc9109a0747
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4366f0048a51612e55228f972bc76311ca69283b7e04ea22c463bcd3ae6a049d943f989b559ea25c9d69070f3afaaf2cfc5986afb46cd0e6c4094f5ee42b4d19
|
|
7
|
+
data.tar.gz: 7ad825094966140dccefbc112ace422d68986a6d6707ac7116fede8a215e3bf4bfce0250335c5efd773a4d39d9472b33ae27a15eb835ff8097828c236d015789
|
data/README.md
CHANGED
|
@@ -68,9 +68,13 @@ HubKernel::Interface::CallReasons.refuse_unlisted_values(Supplies, "price_of", v
|
|
|
68
68
|
HubKernel::Interface::CallReasons.missing_record(error) # => "No consumable has the id 7"
|
|
69
69
|
```
|
|
70
70
|
|
|
71
|
-
`refuse_unlisted_values`
|
|
72
|
-
|
|
73
|
-
|
|
71
|
+
`refuse_unlisted_values` does nothing for a call that sends only listed values, and asks the
|
|
72
|
+
permission check nothing. For a call that sends any other value, it asks the permission check
|
|
73
|
+
once about the called method, raises `HubKernel::NotAllowed` when it refuses, and otherwise
|
|
74
|
+
raises `HubKernel::Refused` naming the method and every value it is not listed with.
|
|
75
|
+
|
|
76
|
+
`Supplies.allows?("price_of", person: person, account: account)` asks the permission check
|
|
77
|
+
about that one method. `missing_record` reads the error's `model` and `id`.
|
|
74
78
|
|
|
75
79
|
`Supplies.exposure_problems` names each exposed method the hub has no method for, or lists
|
|
76
80
|
with values it does not take. `HubKernel::Interface::ExposingHubs.list` holds every hub that
|
data/lib/hub_kernel/exposes.rb
CHANGED
|
@@ -29,6 +29,12 @@ module HubKernel
|
|
|
29
29
|
exposures.select { |exposure| allowed?(exposure, person, account) }
|
|
30
30
|
end
|
|
31
31
|
|
|
32
|
+
def allows?(name, person:, account:)
|
|
33
|
+
refuse_without_caller(person, account)
|
|
34
|
+
|
|
35
|
+
allowed?(exposed(name), person, account)
|
|
36
|
+
end
|
|
37
|
+
|
|
32
38
|
def call_exposed(name, values:, person:, account:)
|
|
33
39
|
refuse_without_caller(person, account)
|
|
34
40
|
|
|
@@ -4,9 +4,10 @@ module HubKernel
|
|
|
4
4
|
module Interface
|
|
5
5
|
module CallReasons
|
|
6
6
|
def self.refuse_unlisted_values(hub, name, values:, person:, account:)
|
|
7
|
-
raise HubKernel::NotAllowed, "#{hub.name.demodulize} #{name}" unless hub.exposures_for(person: person, account: account).any? { |exposure| exposure.name.to_s == name.to_s }
|
|
8
|
-
|
|
9
7
|
unlisted = values.keys - hub.exposed(name).takes
|
|
8
|
+
return if unlisted.none?
|
|
9
|
+
|
|
10
|
+
raise HubKernel::NotAllowed, "#{hub.name.demodulize} #{name}" unless hub.allows?(name, person: person, account: account)
|
|
10
11
|
raise HubKernel::Refused, "#{name} does not take #{unlisted.join(", ")}" if unlisted.any?
|
|
11
12
|
end
|
|
12
13
|
|