Class: CloudConfig::Providers::InMemory

Inherits:
Object
  • Object
show all
Defined in:
lib/cloud-config/providers/in_memory.rb

Overview

A class that acts as a provider for storing configuration in-memory

Examples:

provider = CloudConfig::Providers::InMemory.new # Assuming AWS credentials are already configured
provider.set(:example_key, :example_value)
provider.get(:example_key) #=> 'example_value'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(_opts = {}) ⇒ InMemory

Create an instance of CloudConfig::Providers::InMemory



17
18
19
# File 'lib/cloud-config/providers/in_memory.rb', line 17

def initialize(_opts = {})
  @settings = {}
end

Instance Attribute Details

#settingsObject (readonly)

Returns the value of attribute settings.



14
15
16
# File 'lib/cloud-config/providers/in_memory.rb', line 14

def settings
  @settings
end

Instance Method Details

#get(key, _opts = {}) ⇒ Object

Fetch the value of the key

Parameters:

  • key (String, Symbol)

    Key to fetch

Returns:

  • (Object)

    Value of the key



26
27
28
# File 'lib/cloud-config/providers/in_memory.rb', line 26

def get(key, _opts = {})
  settings[key]
end

#set(key, value) ⇒ Object

Set the value of the key

Parameters:

  • key (String, Symbol)

    Key to set

  • value (Object)

    Value of the key



34
35
36
# File 'lib/cloud-config/providers/in_memory.rb', line 34

def set(key, value)
  @settings[key] = value
end