Parent

Included Modules

Files

Caricature::ClrIsolator

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.

Public Class Methods

new(context) click to toggle source

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
12:     def initialize(context)
13:       super
14:       instance = nil
15:       sklass = context.subject
16:       unless context.subject.respond_to?(:class_eval)
17:         sklass = context.subject.class
18:         instance = context.subject
19:       end
20:       @descriptor = ClrClassDescriptor.new sklass
21:       instance ||= sklass.new unless sklass.to_clr_type.is_abstract
22:       build_isolation sklass, instance
23:     end
new(*args) click to toggle source

(Not documented)

    # File lib/caricature/clr/isolator.rb, line 45
45:         def initialize(*args)  
46:           self                      
47:         end

Public Instance Methods

___super___() click to toggle source

access to the proxied subject

    # File lib/caricature/clr/isolator.rb, line 41
41:         def ___super___
42:           isolation_context.instance
43:         end
create_isolation_for(subj) click to toggle source

builds the Isolator class for the specified subject

    # File lib/caricature/clr/isolator.rb, line 31
31:     def  create_isolation_for(subj)
32:       members = @descriptor.instance_members
33:       class_members = @descriptor.class_members
34: 
35:       klass = Object.const_set(class_name(subj), Class.new(subj))
36:       klass.class_eval do
37: 
38:         include Interception
39: 
40:         # access to the proxied subject

41:         def ___super___
42:           isolation_context.instance
43:         end      
44:         
45:         def initialize(*args)  
46:           self                      
47:         end
48: 
49:         members.each do |mem|
50:           nm = mem.name.to_s.to_sym
51:           define_method nm do |*args|
52:             b = nil
53:             b = Proc.new { yield } if block_given?
54:             isolation_context.send_message(nm, mem.return_type, *args, &b)
55:           end unless nm == :to_string
56:         end
57: 
58:         class_members.each do |mn|
59:           mn = mn.name.to_s.to_sym
60:           define_cmethod mn do |*args|
61:             b = nil
62:             b = Proc.new { yield } if block_given?
63:             isolation_context.send_class_message(mn, nil, *args, &b)
64:           end
65:         end
66: 
67:       end
68: 
69:       klass
70:     end
initialize_messenger() click to toggle source

initializes the messaging strategy for the isolator

    # File lib/caricature/clr/isolator.rb, line 26
26:     def initialize_messenger
27:       @context.messenger = ClrClassMessenger.new @context.expectations, @subject
28:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.