hub_kernel-api 0.1.0 → 0.2.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: f88a656280e3947879dd6de7324478d0e25a728445ce3f1b4cd90d65bf7e7815
4
- data.tar.gz: a87e442f929a84ed92f128d25824f8e6154a4db93356187a8e29185b02a4541a
3
+ metadata.gz: 1ff8bff7f1990c004e388aac6bbfe08f93f6007263653962a93ee7589d185a24
4
+ data.tar.gz: f79790b1f3a26080b561ce6968142c39aa584742b0a5e037a231165ed00fd0d2
5
5
  SHA512:
6
- metadata.gz: 2ad7cd9a06e4fc669dd54ea6288731b2e07d23aef30be8c8170bff74d8f1517428658a2feabea7ca12bb5d8e4b9b6d8ec4481c10b11b36ca5bbc11487cf29bc0
7
- data.tar.gz: d78ea1612b08e6f4fe694617148ca50a32a1d8d6061066c79fd0dcd5a8ccd2711bd3fc85ad5f1c54693d489bdb872577fc2950ab052c50f1c781d0effac869e8
6
+ metadata.gz: 3d9ee144416f2ab53a5f66aa0e590ab7a784cec6519a49d89336c3dfe0df53bf6ce9ace1cda27644e9e5616ccf08f33bde8e5b04a30b8bc356153ccbffbc716f
7
+ data.tar.gz: fe2a86a74e9e47f6b78b3093d6ac29bd766d706b3b3024762a89f3e80d2936be896d90633b2860f78700cce2f25674035fd8e939d94472e5bd7967850e81993b
data/README.md CHANGED
@@ -28,7 +28,14 @@ mount HubKernel::Api::Engine => "/api/v1/hubs"
28
28
  ```
29
29
 
30
30
  Each exposed method answers at `/<hub>/<method>`, where `<hub>` is the hub's module name
31
- underscored. A read answers GET and a write answers POST, and the answer is the method's
31
+ underscored. To answer at a name of the host's choosing, list the hub as a one-pair hash:
32
+
33
+ ```ruby
34
+ HubKernel::Api.hubs = [ Supplies, { "money" => Billing::Ledger } ]
35
+ ```
36
+
37
+ A hub listed this way answers only at the name given, and the permission check is still
38
+ asked about it by its own name, such as `ledger:record_spend`. A read answers GET and a write answers POST, and the answer is the method's
32
39
  return value under `answer`.
33
40
 
34
41
  | Case | Status | Body |
@@ -1,5 +1,5 @@
1
1
  module HubKernel
2
2
  module Api
3
- VERSION = "0.1.0"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
@@ -9,6 +9,8 @@ module HubKernel
9
9
  mattr_accessor :person_method
10
10
  mattr_accessor :account_method
11
11
 
12
- def self.find(name) = hubs.find { |hub| hub.name.demodulize.underscore == name }
12
+ def self.find(name) = addresses[name]
13
+
14
+ def self.addresses = hubs.reduce({}) { |found, entry| found.merge(entry.is_a?(Hash) ? entry : { entry.name.demodulize.underscore => entry }) }
13
15
  end
14
16
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hub_kernel-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - tylercschneider