Module: Sixty::Instrumented::ClassMethods

Defined in:
lib/sixty/instrumented.rb

Instance Method Summary collapse

Instance Method Details

#method_added(name) ⇒ Object



52
53
54
55
# File 'lib/sixty/instrumented.rb', line 52

def method_added(name)
  super
  Sixty::Instrumented.wrap(self, name) unless name.to_s.start_with?('sixty_')
end

#private(*names) ⇒ Object

── Why visibility has to be followed, not just read ──────────────────

def helper; end followed by private :helper is the common spelling, and at method_added time the method is still public — so it gets wrapped. The wrapper lives in a prepended module, where private on the class does not reach it, and the result is a method the author made private that this gem quietly made public again. That is not a measurement problem; it is a change to the application's API.

So the declarations are followed. A method turned private loses its wrapper entirely rather than becoming a private wrapper: private methods are not instrumented when they are declared private up front, and the two spellings should not disagree.



70
71
72
73
74
# File 'lib/sixty/instrumented.rb', line 70

def private(*names)
  result = super
  Sixty::Instrumented.unwrap(self, names.flatten)
  result
end

#protected(*names) ⇒ Object



76
77
78
79
80
# File 'lib/sixty/instrumented.rb', line 76

def protected(*names)
  result = super
  Sixty::Instrumented.revisibility(self, :protected, names.flatten)
  result
end

#public(*names) ⇒ Object



82
83
84
85
86
# File 'lib/sixty/instrumented.rb', line 82

def public(*names)
  result = super
  Sixty::Instrumented.revisibility(self, :public, names.flatten)
  result
end

#sixty_install_wrapper!Object



48
49
50
# File 'lib/sixty/instrumented.rb', line 48

def sixty_install_wrapper!
  Sixty::Instrumented.wrapper_for(self)
end

#sixty_trace_singleton(*names) ⇒ Object

Opt a class method in too. Rarely what you want — a class method is usually a constructor or a lookup — but a Service.call entry point is common enough to be worth the two lines.



91
92
93
# File 'lib/sixty/instrumented.rb', line 91

def sixty_trace_singleton(*names)
  names.each { |name| Sixty::Instrumented.wrap_singleton(self, name) }
end