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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b0fa91bb8d315c37de4f4d2aadb2c12e924b092b763b2d932eecf0a0adb161d8
4
- data.tar.gz: bccf1208493a973a64cb76df47226cd638d375aa38e3dfa34f18e801a4fba94f
3
+ metadata.gz: 46efe9234db5355c30fb8e4860fb8183028c7d41fb5e4ca4172d5f939bf0aee8
4
+ data.tar.gz: a0108815b76bd611f424978603340d9c1901d8e5d0632e78f1482dc9109a0747
5
5
  SHA512:
6
- metadata.gz: 2114bad113c0a16a3f6a85b59a01f887928980fa69f334e32dcdb19f5ca7ac1397c234d67779d8c5ba275c794254cbb673a6fc3db5f5b2fb6c0d35858acc587c
7
- data.tar.gz: 90e57ae0a730030c16c895f94d6011c99d371bb7443668e935c681b95f1a58b0de8440bc0bf011f6b5110583b173100bfae214241215afe5f9ad0b3783b75d7a
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` 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`.
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
@@ -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
 
@@ -1,5 +1,5 @@
1
1
  module HubKernel
2
2
  module Interface
3
- VERSION = "0.5.0"
3
+ VERSION = "0.6.0"
4
4
  end
5
5
  end
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.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - tylercschneider