Included Modules

Files

Caricature::ClrInterfaceIsolator

An Isolator for CLR interfaces. this implements all the methods that are defined on the interface.

Public Class Methods

new(context) click to toggle source

Implementation of the template method that creates an isolator for an interface defined in a CLR language.

     # File lib/caricature/clr/isolator.rb, line 201
201:     def initialize(context)
202:       super
203:       sklass = context.subject
204:       @descriptor = ClrInterfaceDescriptor.new sklass
205:       build_isolation sklass
206:     end

Public Instance Methods

create_isolation_for(subj) click to toggle source

builds the actual isolator for the CLR interface

     # File lib/caricature/clr/isolator.rb, line 214
214:     def create_isolation_for(subj)
215:       proxy_members = @descriptor.instance_members
216:       events = @descriptor.events
217: 
218:       klass = Object.const_set(class_name(subj), Class.new)
219:       klass.class_eval do
220: 
221:         include subj
222:         include Interception
223: 
224:         proxy_members.each do |mem|
225:           nm = mem.name.to_s.to_sym
226:           define_method nm do |*args|
227:             b = nil
228:             b = Proc.new { yield } if block_given?
229:             isolation_context.send_message(nm, mem.return_type, *args, &b)
230:           end
231:         end
232: 
233: 
234:       end
235: 
236:       evts = events.collect do |evt|
237:        %(add remove).inject("") do |res, nm|
238:          res << def #{"self." unless evt.instance_member?}#{nm}_#{evt.event_name}(block)  isolation_context.#{nm}_event_subscription('#{evt.event_name}', :#{evt.instance_member? ? "instance" : "class"}, block)end
239:        end
240:       end.join("\n")
241:       klass.class_eval evts
242: 
243:       klass
244:     end
initialize_messenger() click to toggle source

initializes the messaging strategy for the isolator

     # File lib/caricature/clr/isolator.rb, line 209
209:     def initialize_messenger
210:       @context.messenger = ClrInterfaceMessenger.new @context.expectations
211:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.