Sha256: ad882d702e93e379f524dd2d4f59e524549b8ea81df721b3a25464ec84161ef9
Contents?: true
Size: 880 Bytes
Versions: 2
Compression:
Stored size: 880 Bytes
Contents
require 'habu/annotation_collector_helper' module Habu class AnnotationCollector using ::Habu::AnnotationCollectorHelper attr_reader :constructor_annotations def initialize @constructor_annotations = [] @iseq_interceptor = new_iseq_interceptor end def install RubyVM::InstructionSequence.singleton_class.prepend(@iseq_interceptor) end private def add_constructor_annotation(klass) @constructor_annotations << klass end def new_iseq_interceptor add_constructor_annotation = self.:add_constructor_annotation Module.new do define_method :load_iseq do |fname| ast = RubyVM::AbstractSyntaxTree.parse_file(fname) ast.each_constructor_annotations(&add_constructor_annotation) RubyVM::InstructionSequence.compile_file(fname) end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
habu-0.2.0 | lib/habu/annotation_collector.rb |
habu-0.1.1 | lib/habu/annotation_collector.rb |