Sha256: c76f3f3513eea1a19744502476b069ed6ed6c5fbfb4385e75818c22a387544b2

Contents?: true

Size: 664 Bytes

Versions: 1

Compression:

Stored size: 664 Bytes

Contents

# Author::    Nicolas Pouillard  <ertai@lrde.epita.fr>.
# Copyright:: Copyright (c) 2005 Nicolas Pouillard. All rights reserved.
# License::   GNU General Public License (GPL).
# Revision::  $Id: verbose_object.rb 222 2005-05-09 12:44:32Z ertai $

class VerboseObject

  def initialize ( anObject )
    @obj = anObject
  end

  instance_methods.each do |meth|
    next if meth =~ /__.*__/
    module_eval %Q{
      def #{meth} ( *a, &b )
        log(:#{meth}, *a)
        @obj.__send__(:#{meth}, *a, &b)
      end
    }
  end

  def log ( *a )
    STDERR.puts "LOG: #{a.inspect}"
  end

  def method_missing ( *a, &b )
    log(*a)
  end

end # class VerboseObject

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vcs-0.2.148 ruby_ex/verbose_object.rb