Module: Gemmy::Patches::HashPatch::PersistedHash

Defined in:
lib/gemmy/patches/hash_patch.rb

Overview

Helper methods for the persistence patch

Instance Method Summary collapse

Instance Method Details

#clearObject



305
306
307
308
309
# File 'lib/gemmy/patches/hash_patch.rb', line 305

def clear
  autovivified = Gemmy.patch("hash/i/autovivified")\
                      .method(:_autovivified)
  @store.transaction { @store[:data] = autovivified.call({}) }
end

#dataObject



302
303
304
# File 'lib/gemmy/patches/hash_patch.rb', line 302

def data
  @store.transaction { @store[:data] }
end

#get(*keys, disk: true) ⇒ Object



291
292
293
# File 'lib/gemmy/patches/hash_patch.rb', line 291

def get(*keys, disk: true)
  disk ? @store.transaction { @store[:data].dig(*keys) } : dig(*keys)
end

#set(*keys, val) ⇒ Object



294
295
296
297
298
299
300
301
# File 'lib/gemmy/patches/hash_patch.rb', line 294

def set(*keys, val)
  bury = Gemmy::Patches::HashPatch::InstanceMethods::Bury.method(:_bury)
  bury.call(self, *keys, val)
  @store.transaction do
    bury.call(@store[:data], *(keys + [val]))
  end
  val
end