Class: Sc4ry::Backends::Memory

Inherits:
Object
  • Object
show all
Defined in:
lib/sc4ry/backends/memory.rb

Overview

class of the memory backend

Instance Method Summary collapse

Constructor Details

#initialize(_config = nil?) ) ⇒ Sc4ry::Backends::Memory

Constructor

Parameters:

  • config (Hash)

    Config map



14
15
16
# File 'lib/sc4ry/backends/memory.rb', line 14

def initialize(_config = nil?)
  @data = {}
end

Instance Method Details

#del(key:) ⇒ Boolean

delete a specific record

Parameters:

  • params (Symbol)

    the name of the record

Returns:

  • (Boolean)

    status of the operation



42
43
44
# File 'lib/sc4ry/backends/memory.rb', line 42

def del(key:)
  @data.delete key
end

#exist?(key:) ⇒ Boolean

verifiy a specific record existence

Parameters:

  • key (Symbol)

    the name of the record

Returns:

  • (Boolean)

    presence of the record



55
56
57
# File 'lib/sc4ry/backends/memory.rb', line 55

def exist?(key:)
  @data.include? key
end

#flushBoolean

flush all records in backend

Returns:

  • (Boolean)

    status of the operation



48
49
50
# File 'lib/sc4ry/backends/memory.rb', line 48

def flush
  @data.clear
end

#get(key:) ⇒ String

return value of queried record

Parameters:

  • key (Symbol)

    the name of the record

Returns:

  • (String)

    content value of record



27
28
29
# File 'lib/sc4ry/backends/memory.rb', line 27

def get(key:)
  @data[key]
end

#listArray

return the list of find records in backend for a specific pattern

Returns:

  • (Array)

    list of record (for all hostname if hostname is specified)



20
21
22
# File 'lib/sc4ry/backends/memory.rb', line 20

def list
  @data.keys
end

#put(key:, value:) ⇒ String

defined and store value for specified key

Parameters:

  • key (Symbol)

    :key the name of the record

  • value (Symbol)

    :value the content value of the record

Returns:

  • (String)

    content value of record



35
36
37
# File 'lib/sc4ry/backends/memory.rb', line 35

def put(key:, value:)
  @data[key] = value
end