lib/surrogate/hatchling.rb in surrogate-0.2.0 vs lib/surrogate/hatchling.rb in surrogate-0.3.0
- old
+ new
@@ -1,7 +1,10 @@
class Surrogate
UnknownMethod = Class.new StandardError
+
+ # This contains the unique behaviour for each instance
+ # It handles method invocation and records the appropriate information
class Hatchling
attr_accessor :instance, :hatchery
def initialize(instance, hatchery)
self.instance, self.hatchery = instance, hatchery
@@ -13,9 +16,11 @@
def invoke_method(method_name, args, &block)
invoked_methods[method_name] << args
return get_default method_name, args unless has_ivar? method_name
ivar = get_ivar method_name
+
+ # This may soon need classes for each type which know how to invoke themselves
case ivar
when MethodQueue
play_from_queue ivar, method_name
when Exception
raise ivar