Included Modules

Files

Caricature::RubyIsolator

A proxy to Ruby objects that records method calls this implements all the instance methods that are defined on the class.

Public Class Methods

new(context) click to toggle source

implemented template method for creating Ruby isolations

     # File lib/caricature/isolator.rb, line 243
243:     def initialize(context)
244:       super
245:       klass = @context.subject.respond_to?(:class_eval) ? @context.subject : @context.subject.class
246:       inst = @context.subject.respond_to?(:class_eval) ? nil : @context.subject
247:       # inst = @context.subject.respond_to?(:class_eval) ? @context.subject.new : @context.subject            
248:       @descriptor = RubyObjectDescriptor.new klass
249:       build_isolation klass, inst
250:     end
new(*args) click to toggle source
     # File lib/caricature/isolator.rb, line 281
281:         def initialize(*args)  
282:           self                      
283:         end

Public Instance Methods

___super___() click to toggle source

access to the proxied subject

     # File lib/caricature/isolator.rb, line 268
268:         def ___super___
269:           isolation_context.instance
270:         end
create_isolation_for(subj) click to toggle source

creates the ruby isolator for the specified subject

     # File lib/caricature/isolator.rb, line 258
258:     def create_isolation_for(subj)
259:       imembers = @descriptor.instance_members
260:       cmembers = @descriptor.class_members
261: 
262:       klass = Object.const_set(class_name(subj), Class.new(subj))
263:       klass.class_eval do
264: 
265:         include Interception
266: 
267:         # access to the proxied subject
268:         def ___super___
269:           isolation_context.instance
270:         end
271: 
272:         imembers.each do |mn|
273:           mn = mn.name.to_s.to_sym
274:           define_method mn do |*args|
275:             b = nil
276:             b = Proc.new { yield } if block_given?  
277:             isolation_context.send_message(mn, nil, *args, &b)
278:           end
279:         end  
280:         
281:         def initialize(*args)  
282:           self                      
283:         end 
284:         
285:         cmembers.each do |mn|
286:           mn = mn.name.to_s.to_sym
287:           define_cmethod mn do |*args|        
288:             return if mn.to_s =~ /$(singleton_)?method_added/ and args.first.to_s =~ /$(singleton_)?method_added/
289:             b = nil
290:             b = Proc.new { yield } if block_given?  
291:             isolation_context.send_class_message(mn, nil, *args, &b)
292:           end
293:         end   
294: 
295:       end
296: 
297:       klass
298:     end
initialize_messenger() click to toggle source

initializes the messaging strategy for the isolator

     # File lib/caricature/isolator.rb, line 253
253:     def initialize_messenger
254:       @context.messenger = RubyMessenger.new @context.expectations, @subject
255:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.