Module: Cts::Mpx::Registry
- Defined in:
- lib/cts/mpx/registry.rb
Overview
Set of procedural functions to interact with the Registry.
Class Method Summary collapse
-
.domains ⇒ Hash
Collection of domains stored in memory.
-
.fetch_and_store_domain(user, account_id = 'urn:theplatform:auth:root') ⇒ Hash
Call fetch and store domain in sequence.
-
.fetch_domain(user, account_id = 'urn:theplatform:auth:root') ⇒ Hash
Fetch a domain from the registry.
-
.initialize ⇒ Object
find and store the root registry from the US.
-
.store_domain(data, account_id = 'urn:theplatform:auth:root') ⇒ Void
Store the domain in memory.
Class Method Details
.domains ⇒ Hash
Collection of domains stored in memory
9 10 11 |
# File 'lib/cts/mpx/registry.rb', line 9 def domains @domains end |
.fetch_and_store_domain(user, account_id = 'urn:theplatform:auth:root') ⇒ Hash
Call fetch and store domain in sequence.
18 19 20 21 22 23 |
# File 'lib/cts/mpx/registry.rb', line 18 def fetch_and_store_domain(user, account_id = 'urn:theplatform:auth:root') account_id ||= 'urn:theplatform:auth:root' result = fetch_domain user, account_id store_domain result, account_id domains[account_id] end |
.fetch_domain(user, account_id = 'urn:theplatform:auth:root') ⇒ Hash
Fetch a domain from the registry.
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/cts/mpx/registry.rb', line 31 def fetch_domain(user, account_id = 'urn:theplatform:auth:root') return domains['urn:theplatform:auth:root'] if account_id == 'urn:theplatform:auth:root' Driver::Exceptions.raise_unless_argument_error?(user, 'User') { !user.is_a? User } user.token! Driver::Exceptions.raise_unless_argument_error?(account_id, 'account_id') { !Validators.account_id? account_id } response = Services::Web.post user: user, service: 'Access Data Service', endpoint: 'Registry', method: 'resolveDomain', arguments: { 'accountId' => account_id } response.data['resolveDomainResponse'] end |
.initialize ⇒ Object
find and store the root registry from the US
57 58 59 60 61 |
# File 'lib/cts/mpx/registry.rb', line 57 def initialize @domains = {} content = File.read "#{Driver.config_dir}/root_registry_sea1.json" store_domain(Driver.parse_json(content)['resolveDomainResponse'], 'urn:theplatform:auth:root') end |
.store_domain(data, account_id = 'urn:theplatform:auth:root') ⇒ Void
Store the domain in memory
48 49 50 51 52 53 54 |
# File 'lib/cts/mpx/registry.rb', line 48 def store_domain(data, account_id = 'urn:theplatform:auth:root') raise ArgumentError, "#{account_id} is not a valid account_id" unless Validators.account_id? account_id raise ArgumentError, "#{data} is not a valid Hash" unless data.is_a? Hash @domains.store account_id, data nil end |