Sha256: ee4c2a71bbaee26a30d46c8e6c5e8ff505e42b68ffc1c408f8d5594b1c4cfb94

Contents?: true

Size: 676 Bytes

Versions: 9

Compression:

Stored size: 676 Bytes

Contents

class ClassModule < Module
  undef_method :singleton_method_added
end

class Module

  # Be nice if this could be a constant instead.
  def ClassModule
    @_ClassModule_ ||= ::ClassModule.new
  end
    
  def singleton_method_added( m )
    mod = self
    mod::ClassModule().module_eval {
      define_method( m, &mod.method(m) )
    }
  end

  def inherit( mod )
    include mod
    extend mod::ClassModule()
  end
  
end



#=begin test

module M
  def self.hello ; "Hello" ; end
  def hello ; "hello" ; end
end

class X
  inherit M
end

p X.hello
p X.new.hello

module N
  inherit M
end

p X.hello
p X.new.hello

class Y
  inherit N
end

p Y.hello
p Y.new.hello


#=end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
facets-1.4.2 forge/core/module/inherit0.rb
facets-1.4.1 forge/core/module/inherit.rb
facets-1.4.3 forge/core/module/inherit0.rb
facets-1.4.5 snip/core/module/inherit0.rb
facets-1.4.4 forge/core/module/inherit0.rb
facets-1.8.49 work/core/module/inherit0.rb
facets-1.8.0 work/core/module/inherit0.rb
facets-1.8.20 work/core/module/inherit0.rb
facets-1.8.8 work/core/module/inherit0.rb