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.



278
279
280
# File 'lib/s3fsr.rb', line 278

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



281
282
283
284
285
286
287
288
289
290
291
292
293
294
# File 'lib/s3fsr.rb', line 281

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