diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2016-06-14 14:28:40 +0000 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2016-06-14 14:28:40 +0000 |
commit | f558bf0de4d040dd824136b07d60af7eebef0084 (patch) | |
tree | fcdf53ffdbe96f835382d7dc6b147936afd3baea /lib | |
parent | d4cd6dcaa024f8eca9089e67fb9b97022696d3e0 (diff) | |
parent | dadc531353bdf0e384d05d173d19756b0d9fba13 (diff) | |
download | gitlab-ce-f558bf0de4d040dd824136b07d60af7eebef0084.tar.gz |
Merge branch '18527-instrument-private-methods' into 'master'
Instrument private methods and instance private methods
See merge request !4639
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/metrics/instrumentation.rb | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/gitlab/metrics/instrumentation.rb b/lib/gitlab/metrics/instrumentation.rb index ad9ce3fa442..d81d26754fe 100644 --- a/lib/gitlab/metrics/instrumentation.rb +++ b/lib/gitlab/metrics/instrumentation.rb @@ -56,7 +56,7 @@ module Gitlab end end - # Instruments all public methods of a module. + # Instruments all public and private methods of a module. # # This method optionally takes a block that can be used to determine if a # method should be instrumented or not. The block is passed the receiving @@ -65,7 +65,8 @@ module Gitlab # # mod - The module to instrument. def self.instrument_methods(mod) - mod.public_methods(false).each do |name| + methods = mod.methods(false) + mod.private_methods(false) + methods.each do |name| method = mod.method(name) if method.owner == mod.singleton_class @@ -76,13 +77,14 @@ module Gitlab end end - # Instruments all public instance methods of a module. + # Instruments all public and private instance methods of a module. # # See `instrument_methods` for more information. # # mod - The module to instrument. def self.instrument_instance_methods(mod) - mod.public_instance_methods(false).each do |name| + methods = mod.instance_methods(false) + mod.private_instance_methods(false) + methods.each do |name| method = mod.instance_method(name) if method.owner == mod |