Sha256: c822adcca84a9a26f6f418cef8885117cd4091440caf493fbb01366745eafceb
Contents?: true
Size: 756 Bytes
Versions: 1
Compression:
Stored size: 756 Bytes
Contents
require "forwardable" module Undo class Wrapper < SimpleDelegator extend Forwardable def_delegators :object, :class, :kind_of? attr_reader :uuid def initialize(object, options = {}) @object = object @mutator_methods = options.delete(:mutator_methods) || [] @uuid = object.respond_to?(:uuid) ? object.uuid : options.fetch(:uuid) @options = options super object end def method_missing(method, *args, &block) store if mutator_methods.include? method super method, *args, &block end private attr_reader :object, :options def mutator_methods Kernel.Array(@mutator_methods) end def store Undo.store object, options.merge(uuid: uuid) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
undo-0.1.1 | lib/undo/wrapper.rb |