Module: Ephemeron::Store::Update

Defined in:
lib/ephemeron/store/update.rb

Class Method Summary collapse

Class Method Details

.call(model) ⇒ Object



8
9
10
11
12
13
14
15
16
17
# File 'lib/ephemeron/store/update.rb', line 8

def call(model)
  return unless Store.has? model, as_new_record: true

  Store.add model
  Store.store.delete Convert.call(model, as_new_record: true)

  Store.aliases.find_all { |_, v| v == Convert.call(model, as_new_record: true) }
       .to_h
       .each_key { |key| Store.aliases[key] = Convert.call(model) }
end