Module: Hypostasis::DataModels::KeyValue

Includes:
Utilities
Defined in:
lib/hypostasis/data_models/key_value.rb

Instance Method Summary collapse

Methods included from Utilities

#reconstitute_value

Instance Method Details

#get(key) ⇒ Object



11
12
13
14
15
16
# File 'lib/hypostasis/data_models/key_value.rb', line 11

def get(key)
  key_path = "#{name}\\#{Hypostasis::Tuple.new(key.to_s).to_s}"
  key = database.get_range_start_with(key_path).first.key
  value = database.get_range_start_with(key_path).first.value
  reconstitute_value(Hypostasis::Tuple.unpack(key.to_s.split('\\').last), value)
end

#set(key, value) ⇒ Object



6
7
8
9
# File 'lib/hypostasis/data_models/key_value.rb', line 6

def set(key, value)
  key_path = "#{name}\\#{Hypostasis::Tuple.new(key.to_s, value.class.to_s).to_s}"
  database.set(key_path, value.to_s)
end