Class: ArtirixCacheService::VariablesStores::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/artirix_cache_service/variables_stores/base.rb

Direct Known Subclasses

Internal, Redis

Instance Method Summary collapse

Instance Method Details

#variable_get(given_key, &block) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/artirix_cache_service/variables_stores/base.rb', line 9

def variable_get(given_key, &block)
  key = given_key.to_sym
  val = retrieve(key).presence
  return val.to_s if val
  return nil unless block_given?

  val = block.call
  store key, val
  val.presence && val.to_s
end

#variable_set(key, value) ⇒ Object



20
21
22
23
# File 'lib/artirix_cache_service/variables_stores/base.rb', line 20

def variable_set(key, value)
  store key.to_sym, value
  self
end

#variablesObject



5
6
7
# File 'lib/artirix_cache_service/variables_stores/base.rb', line 5

def variables
  raise 'abstract method not overridden'
end