Class: Katalyst::Healthcheck::Store::Memory

Inherits:
Object
  • Object
show all
Defined in:
lib/katalyst/healthcheck/store/memory.rb

Overview

In-memory store, intended for spec tests and debugging

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Memory

Returns a new instance of Memory.



12
13
14
15
# File 'lib/katalyst/healthcheck/store/memory.rb', line 12

def initialize(options = {})
  @options = options
  @state   = {}
end

Instance Attribute Details

#stateObject (readonly)

Returns the value of attribute state.



10
11
12
# File 'lib/katalyst/healthcheck/store/memory.rb', line 10

def state
  @state
end

Instance Method Details

#delete(name) ⇒ Object

Remove task state

Parameters:

  • name (String)

    name of the task



36
37
38
# File 'lib/katalyst/healthcheck/store/memory.rb', line 36

def delete(name)
  update(name, nil)
end

#readArray<Hash>

Read state from memory

Returns:

  • (Array<Hash>)

    List of tasks attribute data



19
20
21
# File 'lib/katalyst/healthcheck/store/memory.rb', line 19

def read
  state.values
end

#update(name, task_state = {}) ⇒ Object

Write state to memory

Parameters:

  • name (String)

    name of the task

  • task_state (Hash, nil) (defaults to: {})

    Task state



26
27
28
29
30
31
32
# File 'lib/katalyst/healthcheck/store/memory.rb', line 26

def update(name, task_state = {})
  if task_state.nil?
    state.delete(name)
  else
    state[name] = task_state
  end
end