Class Index [+]

Quicksearch

Spec::Example::ModuleReopeningFix

When you reopen a module that is included in another module that is included in a class, the new material you define does not make it to the class. This fixes that.

Example

  module M1; end

  module M2
    def foo; "FOO"; end
  end

  class C
    include M1
  end

  module M1
    include M2
  end

  c = C.new
  c.foo
  NoMethodError: undefined method `foo' for #<C:0x5e89a4>
    from (irb):12

Public Instance Methods

child_modules() click to toggle source
    # File lib/spec/example/module_reopening_fix.rb, line 27
27:       def child_modules
28:         @child_modules ||= []
29:       end
include(mod) click to toggle source
    # File lib/spec/example/module_reopening_fix.rb, line 35
35:       def include(mod)
36:         super
37:         child_modules.each do |child_module|
38:           child_module.__send__(:include, mod)
39:         end
40:       end
included(mod) click to toggle source
    # File lib/spec/example/module_reopening_fix.rb, line 31
31:       def included(mod)
32:         child_modules << mod
33:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.