Class: Undo::Keeper

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/undo/keeper.rb

Instance Method Summary collapse

Constructor Details

#initialize(config, options) ⇒ Keeper

Returns a new instance of Keeper.



7
8
9
10
# File 'lib/undo/keeper.rb', line 7

def initialize(config, options)
  @config = config.with options
  @options = config.filter options
end

Instance Method Details

#delete(uuid) ⇒ Object



24
25
26
# File 'lib/undo/keeper.rb', line 24

def delete(uuid)
  storage.delete uuid, options
end

#restore(uuid) ⇒ Object



19
20
21
22
# File 'lib/undo/keeper.rb', line 19

def restore(uuid)
  reflection = storage.fetch uuid, options
  serializer.deserialize reflection, options
end

#store(object) ⇒ Object



12
13
14
15
16
17
# File 'lib/undo/keeper.rb', line 12

def store(object)
  build_uuid(object).tap do |uuid|
    reflection = serializer.serialize object, options
    storage.store uuid, reflection, options
  end
end