Isolator
A proxy to CLR objects that records method calls. this implements all the public instance methods of the class when you use it in ruby code When you use it in a CLR class you’re bound to CLR rules and it only overrides the methods that are marked as virtual. We also can’t isolate static or sealed types at the moment.
Implementation of the template method that creates an isolator for a class defined in a CLR language.
# File lib/caricature/clr/isolator.rb, line 12 def initialize(context) super instance = nil sklass = context.subject unless context.subject.respond_to?(:class_eval) sklass = context.subject.class instance = context.subject end @descriptor = ClrClassDescriptor.new sklass build_isolation sklass, (instance || sklass.new) end
access to the proxied subject
# File lib/caricature/clr/isolator.rb, line 40 def ___super___ isolation_context.instance end
builds the Isolator class for the specified subject
# File lib/caricature/clr/isolator.rb, line 30 def create_isolation_for(subj) members = @descriptor.instance_members class_members = @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 members.each do |mem| nm = mem.name.to_s.to_sym define_method nm do |*args| b = nil b = Proc.new { yield } if block_given? isolation_context.send_message(nm, mem.return_type, *args, &b) end unless nm == :to_string end class_members.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.