Module: Undestroy::Binding::ActiveRecord::Restorable

Defined in:
lib/undestroy/binding/active_record/restorable.rb

Defined Under Namespace

Modules: RelationExtensions

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(receiver) ⇒ Object



21
22
23
24
25
# File 'lib/undestroy/binding/active_record/restorable.rb', line 21

def self.included(receiver)
  receiver.send(:relation).singleton_class.class_eval do
    include Undestroy::Binding::ActiveRecord::Restorable::RelationExtensions
  end
end

Instance Method Details

#restoreObject



3
4
5
6
# File 'lib/undestroy/binding/active_record/restorable.rb', line 3

def restore
  restore_copy
  destroy
end

#restore_copyObject



8
9
10
11
# File 'lib/undestroy/binding/active_record/restorable.rb', line 8

def restore_copy
  config = undestroy_model_binding.config
  config.internals[:restore].new(:target => self, :config => config).run
end