Class: ZombieRecord::Restorable::WithDeletedAssociations

Inherits:
BasicObject
Defined in:
lib/zombie_record/restorable.rb

Overview

Wraps a deleted record and makes sure that any associated record is available even if it is deleted. This is done by intercepting the method calls, checking if the method is an association access, and then ensuring that deleted records are included in the resulting query.

Instance Method Summary collapse

Constructor Details

#initialize(record) ⇒ WithDeletedAssociations

Returns a new instance of WithDeletedAssociations.


91
92
93
# File 'lib/zombie_record/restorable.rb', line 91

def initialize(record)
  @record = record
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object


95
96
97
# File 'lib/zombie_record/restorable.rb', line 95

def method_missing(name, *args, &block)
  delegate_to_record(name) { @record.public_send(name, *args, &block) }
end