Isolator
A proxy to Ruby objects that records method calls this implements all the instance methods that are defined on the class.
implemented template method for creating Ruby isolations
# File lib/caricature/isolator.rb, line 150 def initialize(context) super klass = @context.subject.respond_to?(:class_eval) ? @context.subject : @context.subject.class inst = @context.subject.respond_to?(:class_eval) ? @context.subject.new : @context.subject @descriptor = RubyObjectDescriptor.new klass build_isolation klass, inst end
access to the proxied subject
# File lib/caricature/isolator.rb, line 174 def ___super___ isolation_context.instance end
creates the ruby isolator for the specified subject
# File lib/caricature/isolator.rb, line 164 def create_isolation_for(subj) imembers = @descriptor.instance_members cmembers = @descriptor.class_members klass = Object.const_set(class_name(subj), Class.new(subj)) klass.class_eval do include Interception # access to the proxied subject def ___super___ isolation_context.instance end imembers.each do |mn| mn = mn.name.to_s.to_sym define_method mn do |*args| b = nil b = Proc.new { yield } if block_given? isolation_context.send_message(mn, nil, *args, &b) end end cmembers.each do |mn| mn = mn.name.to_s.to_sym define_cmethod mn do |*args| b = nil b = Proc.new { yield } if block_given? isolation_context.send_message(mn, nil, *args, &b) end end end klass end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.