Class: ConfigurationService::Provider::StubStore
- Inherits:
-
Object
- Object
- ConfigurationService::Provider::StubStore
- Includes:
- Singleton
- Defined in:
- lib/configuration_service/provider/stub_store.rb
Overview
A singleton store for the Stub service provider
Class Method Summary collapse
-
.instance ⇒ ConfigurationService::ProviderRegistry
The singleton registry instance.
Instance Method Summary collapse
-
#delete(identifier) ⇒ Object
Delete configuration data and metadata.
-
#fetch(identifier) ⇒ Array<Hash>
Fetch configuration data and metadata.
-
#store(identifier, data, metadata) ⇒ Object
Store configuration data and metadata.
Class Method Details
.instance ⇒ ConfigurationService::ProviderRegistry
The singleton registry instance
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/configuration_service/provider/stub_store.rb', line 29 class StubStore include Singleton ## # Fetch configuration data and metadata # # @param [String] identifier the configuration identifier # # @return [Array<Hash>] data and metadata as a tuple # def fetch(identifier) @configurations.fetch(identifier) end ## # Store configuration data and metadata # # @param [String] identifier the configuration identifier # @param [Hash] data the configuration data # @param [Hash] metadata the configuration metadata # def store(identifier, data, ) @configurations.store(identifier, [data, ]) end ## # Delete configuration data and metadata # # It is not an error to delete non-existent configuration # # @param [String] identifier the configuration identifier # def delete(identifier) @configurations.delete(identifier) nil end # @private def initialize @configurations = {} end end |
Instance Method Details
#delete(identifier) ⇒ Object
Delete configuration data and metadata
It is not an error to delete non-existent configuration
62 63 64 65 |
# File 'lib/configuration_service/provider/stub_store.rb', line 62 def delete(identifier) @configurations.delete(identifier) nil end |
#fetch(identifier) ⇒ Array<Hash>
Fetch configuration data and metadata
40 41 42 |
# File 'lib/configuration_service/provider/stub_store.rb', line 40 def fetch(identifier) @configurations.fetch(identifier) end |
#store(identifier, data, metadata) ⇒ Object
Store configuration data and metadata
51 52 53 |
# File 'lib/configuration_service/provider/stub_store.rb', line 51 def store(identifier, data, ) @configurations.store(identifier, [data, ]) end |