hub_kernel-interface 0.4.0 → 0.5.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 +12 -0
- data/lib/hub_kernel/interface/call_reasons.rb +16 -0
- data/lib/hub_kernel/interface/version.rb +1 -1
- data/lib/hub_kernel/interface.rb +1 -0
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b0fa91bb8d315c37de4f4d2aadb2c12e924b092b763b2d932eecf0a0adb161d8
|
|
4
|
+
data.tar.gz: bccf1208493a973a64cb76df47226cd638d375aa38e3dfa34f18e801a4fba94f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2114bad113c0a16a3f6a85b59a01f887928980fa69f334e32dcdb19f5ca7ac1397c234d67779d8c5ba275c794254cbb673a6fc3db5f5b2fb6c0d35858acc587c
|
|
7
|
+
data.tar.gz: 90e57ae0a730030c16c895f94d6011c99d371bb7443668e935c681b95f1a58b0de8440bc0bf011f6b5110583b173100bfae214241215afe5f9ad0b3783b75d7a
|
data/README.md
CHANGED
|
@@ -60,6 +60,18 @@ An interface gem's boot check runs `HubKernel::Interface.check!`, which raises
|
|
|
60
60
|
an entry that exposes no methods, two entries that answer at the same name, and each
|
|
61
61
|
problem in a served hub's exposed list.
|
|
62
62
|
|
|
63
|
+
An interface gem checks a call's values before calling, and describes a record the call
|
|
64
|
+
named that does not exist, so every interface gives the same reasons:
|
|
65
|
+
|
|
66
|
+
```ruby
|
|
67
|
+
HubKernel::Interface::CallReasons.refuse_unlisted_values(Supplies, "price_of", values: values, person: person, account: account)
|
|
68
|
+
HubKernel::Interface::CallReasons.missing_record(error) # => "No consumable has the id 7"
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
`refuse_unlisted_values` raises `HubKernel::NotAllowed` when the permission check refuses the
|
|
72
|
+
call, whatever values it sends, and otherwise raises `HubKernel::Refused` naming the method and
|
|
73
|
+
every value it is not listed with. `missing_record` reads the error's `model` and `id`.
|
|
74
|
+
|
|
63
75
|
`Supplies.exposure_problems` names each exposed method the hub has no method for, or lists
|
|
64
76
|
with values it does not take. `HubKernel::Interface::ExposingHubs.list` holds every hub that
|
|
65
77
|
declares an exposed method.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
require "hub_kernel/exposes"
|
|
2
|
+
|
|
3
|
+
module HubKernel
|
|
4
|
+
module Interface
|
|
5
|
+
module CallReasons
|
|
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
|
+
unlisted = values.keys - hub.exposed(name).takes
|
|
10
|
+
raise HubKernel::Refused, "#{name} does not take #{unlisted.join(", ")}" if unlisted.any?
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def self.missing_record(missing) = "No #{missing.model.demodulize.underscore.humanize(capitalize: false)} has the id #{missing.id}"
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
data/lib/hub_kernel/interface.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: hub_kernel-interface
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.5.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- tylercschneider
|
|
@@ -40,6 +40,7 @@ files:
|
|
|
40
40
|
- lib/hub_kernel/context.rb
|
|
41
41
|
- lib/hub_kernel/exposes.rb
|
|
42
42
|
- lib/hub_kernel/interface.rb
|
|
43
|
+
- lib/hub_kernel/interface/call_reasons.rb
|
|
43
44
|
- lib/hub_kernel/interface/exposing_hubs.rb
|
|
44
45
|
- lib/hub_kernel/interface/version.rb
|
|
45
46
|
homepage: https://github.com/DYB-Development/hub_kernel-interface
|