Sha256: 8bf4e4137017291030bb392f5f8fe166faebe16741556e64de82ef3ea04dd622
Contents?: true
Size: 1.04 KB
Versions: 1
Compression:
Stored size: 1.04 KB
Contents
require "undo/version" require "undo/config" require "undo/wrapper" module Undo def self.configure(&block) block_given? ? block.call(config) : config end def self.store(object, options = {}) config.with(options) do |config| uuid(object, options).tap do |uuid| config.storage.put uuid, config.serializer.serialize(object, config.filter(options)) end end end def self.restore(uuid, options = {}) config.with(options) do |config| config.serializer.deserialize config.storage.fetch(uuid), config.filter(options) end end def self.wrap(object, options = {}) options[:uuid] ||= uuid object, options config.with(options) do |config| Wrapper.new object, options.merge(mutator_methods: config.mutator_methods) end end private def self.uuid(object, options = {}) options[:uuid] || config.uuid_generator.call(object) end def self.config @config ||= Undo::Config.new end private_class_method :uuid, :config end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
undo-0.1.1 | lib/undo.rb |