Class: AnnotationMonitor

Inherits:
Object
  • Object
show all
Defined in:
lib/simple-annotations.rb

Constant Summary collapse

@@annotated =
{}
@@before =
TracePoint.new(:call) do |tp|
  selected_class = tp.defined_class.to_s.to_sym
  called_method = tp.method_id
  if AnnotationMonitor.registered.include? selected_class
    annotations = AnnotationMonitor.registered[selected_class][called_method]
    annotations[:before].call if annotations.include? :before
   end
end
@@after =
TracePoint.new(:return) do |tp|
  selected_class = tp.defined_class.to_s.to_sym
  called_method = tp.method_id
  if AnnotationMonitor.registered.include? selected_class
    annotations = AnnotationMonitor.registered[selected_class][called_method]
    annotations[:after].call if annotations.include? :after
   end
end

Class Method Summary collapse

Class Method Details

.register(aClass) ⇒ Object



80
81
82
# File 'lib/simple-annotations.rb', line 80

def AnnotationMonitor::register(aClass)
  @@annotated[aClass] = {}
end

.registeredObject



84
85
86
# File 'lib/simple-annotations.rb', line 84

def AnnotationMonitor::registered
  @@annotated
end