lib/putter/method_creator.rb in putter-0.3.0 vs lib/putter/method_creator.rb in putter-0.4.0

- old
+ new

@@ -1,15 +1,25 @@ module Putter module MethodCreator - def add_putter_method_to_proxy(proxy, eval_method, data) + def add_putter_instance_method_to_proxy(proxy, data) + add_putter_method_to_proxy(proxy, data, :instance_exec) + end + + def add_putter_class_method_to_proxy(proxy, data) + add_putter_method_to_proxy(proxy, data, :module_exec) + end + + private + + def add_putter_method_to_proxy(proxy, data, eval_method) proxy.send(eval_method, data) do |data| define_method(data.method) do |*proxy_args, &blk| line = caller.find {|call| call.match(data.stack_trace_ignore_regex)} - line = line.split(::Dir.pwd)[1] - args_string = proxy_args.to_s - result = super *proxy_args, &blk - ::Putter.configuration.print_strategy.call data.label, line, data.method, args_string, result - result + data.line = line.split(::Dir.pwd)[1] + data.args = proxy_args.to_s + data.result = super *proxy_args, &blk + ::Putter.configuration.print_strategy.call data + data.result end end end end end