Ferenc Engard wrote:
> Hello,
> 
> I
> want a method which will be called when an object is instantiated, if
> the object's Class includes this Module. I.e., I do not want to write a
> 'init_x_module' call into each classes' constructor, which includes this
> module, but want the system call that method. Something like multiple
> inheritance in C++.

In standard ruby:

class Module
   def before(*method_names)
     @before = method_names
   end
   alias pre_beforehack_append_features append_features
   def append_features(klass)
     @before ||= []
     @before.each{|method_name|
       klass.module_eval <<-END_OF_ADVICE
         alias pre_include_#{self}_#{method_name} #{method_name}
         def #{method_name}(*args,&block)
           #{method_name}_#{self}(*args,&block)
           pre_include_#{self}_#{method_name}(*args,&block)
         end
       END_OF_ADVICE
     }
     pre_beforehack_append_features(klass)
   end
end
module M
   before :initialize
   def initialize_M(*args)
     puts "#{self}: initializing M part"
   end
end
class A
   def initialize
     puts "#{self}: initializing A part"
   end
   include M
end

A.new

  => #<A:0x25cb5d8>: initializing M part
     #<A:0x25cb5d8>: initializing A part

The reader may now:
- implement Module#after
- do something intelligent to preserve method arity
- investigate if all of this is not already implemented in AspectR

-- 
   Tobias
(email-address is anti-spammed, remove invalid parts)