Module: ApiDebugger
- Included in:
- Facter
- Defined in:
- lib/util/api_debugger.rb
Class Method Summary collapse
- .parse_options(options) ⇒ Object
-
.prepended(receiver) ⇒ Object
rubocop:disable Metrics/AbcSize.
Class Method Details
.parse_options(options) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/util/api_debugger.rb', line 29 def self.() exclude = [] print_caller = [] .split(',').each do |option| if option.start_with?('-') exclude << option[1..-1].to_sym elsif option.start_with?('+') print_caller << option[1..-1].to_sym end end [exclude, print_caller] end |
.prepended(receiver) ⇒ Object
rubocop:disable Metrics/AbcSize
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/util/api_debugger.rb', line 4 def self.prepended(receiver) # rubocop:disable Metrics/AbcSize exclude, print_caller = (ENV['API_DEBUG']) 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 |