Class: ConfigurationService::Provider::StubStore

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/configuration_service/provider/stub_store.rb

Overview

A singleton store for the Stub service provider

Instance Method Summary collapse

Constructor Details

#initializeStubStore

:nodoc:



16
17
18
# File 'lib/configuration_service/provider/stub_store.rb', line 16

def initialize # :nodoc:
  @configurations = {}
end

Instance Method Details

#delete(identifier) ⇒ Object

Deletes the data and metadata associated with the identifier

It is not an error to delete a non-existent identifier



43
44
45
46
# File 'lib/configuration_service/provider/stub_store.rb', line 43

def delete(identifier)
  @configurations.delete(identifier)
  nil
end

#fetch(identifier) ⇒ Object

Returns the configuration data and metadata for identifier

The dictionaries are returned as an array, to be used as follows:

data,  = StubStore.instance.fetch("acme")


27
28
29
# File 'lib/configuration_service/provider/stub_store.rb', line 27

def fetch(identifier)
  @configurations.fetch(identifier)
end

#store(identifier, data, metadata) ⇒ Object

Stores the data and +metadata associated with the identifier



34
35
36
# File 'lib/configuration_service/provider/stub_store.rb', line 34

def store(identifier, data, )
  @configurations.store(identifier, [data, ])
end