lib/surrogate/endower.rb in surrogate-0.5.4 vs lib/surrogate/endower.rb in surrogate-0.5.5

- old
+ new

@@ -117,11 +117,20 @@ # Custom new, because user can define initialize, and we need to record it # Can we move this into the redefinition of initialize and have it explicitly record itself? def new(*args) instance = allocate + self.last_instance = instance instance.instance_variable_set :@hatchling, Hatchling.new(instance, @hatchery) instance.send :initialize, *args instance + end + + def last_instance + Thread.current["surrogate_last_instance_#{self.object_id}"] + end + + def last_instance=(instance) + Thread.current["surrogate_last_instance_#{self.object_id}"] = instance end end end