Module: Undoer::ClassMethods
- Defined in:
- lib/undoer.rb
Instance Method Summary collapse
Instance Method Details
#restore(options = {}, &block) ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/undoer.rb', line 24 def restore( = {}, &block) target = [:target] errors = [:if_errors] || [StandardError].freeze cloned_target = target.respond_to?('new') ? target.clone : Marshal.load( Marshal.dump(target) ) yield(target) rescue *errors => e raise ArgumentError, "not restoreable!" if target.is_any?(NOT_SUPPORTED) target.deep_copy!(cloned_target) end |