Class: CircuitB::Storage::Memory

Inherits:
Base
  • Object
show all
Defined in:
lib/circuit_b/storage/memory.rb

Instance Method Summary collapse

Constructor Details

#initializeMemory

Returns a new instance of Memory.



7
8
9
# File 'lib/circuit_b/storage/memory.rb', line 7

def initialize
  @fuse_states = {}
end

Instance Method Details

#get(fuse_name, field) ⇒ Object



16
17
18
# File 'lib/circuit_b/storage/memory.rb', line 16

def get(fuse_name, field)
  (@fuse_states[fuse_name] || {})[field.to_sym]
end

#inc(fuse_name, field) ⇒ Object



20
21
22
23
24
# File 'lib/circuit_b/storage/memory.rb', line 20

def inc(fuse_name, field)
  new_val = get(fuse_name, field).to_i + 1
  put(fuse_name, field, new_val)
  return new_val
end

#put(fuse_name, field, value) ⇒ Object



11
12
13
14
# File 'lib/circuit_b/storage/memory.rb', line 11

def put(fuse_name, field, value)
  @fuse_states[fuse_name] ||= {}
  @fuse_states[fuse_name][field.to_sym] = value
end