Class: MethodLogger

Inherits:
Object
  • Object
show all
Defined in:
lib/s3fsr.rb

Instance Method Summary collapse

Constructor Details

#initialize(obj) ⇒ MethodLogger

Returns a new instance of MethodLogger.



337
338
339
# File 'lib/s3fsr.rb', line 337

def initialize(obj)
  @obj = obj
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(sym, *args, &block) ⇒ Object



340
341
342
343
344
345
346
347
348
349
350
351
352
353
# File 'lib/s3fsr.rb', line 340

def method_missing(sym, *args, &block)
  begin
    puts "#{sym}(#{args})" unless sym == :respond_to? or sym == :write_to
    puts "#{sym}(#{args[0].length})" if sym == :write_to
    result = @obj.__send__(sym, *args, &block)
    puts "    #{result}" unless sym == :respond_to? or sym == :read_file
    puts "    #{result.length}" if sym == :read_file
    result
  rescue => e
    puts "    #{e.inspect}"
    puts "    #{e.backtrace}"
    raise $?
  end
end