Method: MaglevRecord::Snapshotable::ClassMethods#reset
- Defined in:
- lib/maglev_record/snapshot/snapshotable.rb
#reset ⇒ Object
resets the class to no methods returns a memento proc that can be called to restore the old state
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/maglev_record/snapshot/snapshotable.rb', line 88 def reset _instance_methods = instance_methods_to_reset.map { |m| meth = instance_method m remove_method m meth } _class_methods = class_methods_to_reset.map { |m| meth = method m singleton_class.remove_method m meth } return Proc.new { instance_methods_to_reset.each { |m| remove_method m } class_methods_to_reset.each{ |m| singleton_class.remove_method m } _instance_methods.each{|m| define_method m.name, m } _class_methods.each{|m| singleton_class.define_method m.name, m } self } end |