6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/facter/util/api_debugger.rb', line 6
def self.prepended(receiver)
exclude, print_caller = parse_options(ENV.fetch('API_DEBUG', nil))
receiver_methods = receiver.instance_methods - Object.methods
receiver_methods.each do |meth|
ApiDebugger.class_eval do
define_method(meth) do |*args|
method_call = super(*args)
unless exclude.include?(meth)
puts '#' * 80
puts "Method call: #{meth}"
puts "Called with: #{args.inspect}"
if print_caller.include?(meth)
puts '-' * 80
puts caller
end
puts '#' * 80
end
method_call
end
end
end
end
|