lib/undo/wrapper.rb in undo-0.1.0 vs lib/undo/wrapper.rb in undo-0.1.1

- old
+ new

@@ -4,26 +4,31 @@ class Wrapper < SimpleDelegator extend Forwardable def_delegators :object, :class, :kind_of? attr_reader :uuid - def initialize(object, uuid, options = {}) + def initialize(object, options = {}) @object = object - @mutator_methods = options.fetch :mutator_methods, [] - @uuid = object.respond_to?(:uuid) ? object.uuid : uuid + @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, :mutator_methods + attr_reader :object, :options + def mutator_methods + Kernel.Array(@mutator_methods) + end + def store - Undo.store object, uuid: uuid + Undo.store object, options.merge(uuid: uuid) end end end