Public instance methods
generate_packed_method
()
Creates a method definition (for an eval). The method is named +@meth+ and it calls +@methorig+.
The new method adds a Mark to the thread timeline before and after +@alias+ is called. It also adds a Range to the timeline based on the two marks.
[show source]
# File lib/benelux/packer.rb, line 116 116: def generate_packed_method 117: %Q{ 118: def #{@meth}(*args, &block) 119: #p ["#{@meth} 1"] 120: call_id = "" << self.object_id.abs.to_s << args.object_id.abs.to_s 121: Benelux.current_track :global unless Benelux.known_thread? 122: mark_a = Benelux.current_track.timeline.add_mark :'#{@aliaz}_a' 123: mark_a.add_tag :call_id => call_id 124: tags = mark_a.tags 125: ret = #{@methorig}(*args, &block) 126: #p ["#{@meth} 2"] 127: ret 128: rescue => ex # We do this so we can use 129: raise ex # ex in the ensure block. 130: ensure 131: mark_z = Benelux.current_track.timeline.add_mark :'#{@aliaz}_z' 132: mark_z.tags = tags # In case tags were added between these marks 133: range = Benelux.current_track.timeline.add_range :'#{@aliaz}', mark_a, mark_z 134: range.exception = ex if defined?(ex) && !ex.nil? 135: end 136: } 137: end
install_method
()
This method executes the method definition created by generate_method. It calls @klass.module_eval with the modified line number (helpful for exceptions)
[show source]
# File lib/benelux/packer.rb, line 106 106: def install_method 107: @klass.module_eval generate_packed_method, __FILE__, 94 108: end