Sha256: 91f61dcdcbb7131b6197a1cde2bf5f1e1017add11589ce74b6b33c6f9bfce7d8

Contents?: true

Size: 890 Bytes

Versions: 34

Compression:

Stored size: 890 Bytes

Contents

module Spec
  module Example
    # 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
    module ModuleReopeningFix
      def child_modules
        @child_modules ||= []
      end

      def included(mod)
        child_modules << mod
      end

      def include(mod)
        super
        child_modules.each do |child_module|
          child_module.__send__(:include, mod)
        end
      end
    end
  end
end

Version data entries

34 entries across 34 versions & 11 rubygems

Version Path
rspec-instructure-1.3.3 lib/spec/example/module_reopening_fix.rb
radiant-1.0.0 ruby-debug/ruby/1.8/gems/rspec-1.3.2/lib/spec/example/module_reopening_fix.rb
rspec-1.3.2 lib/spec/example/module_reopening_fix.rb
rspec-1.3.1 lib/spec/example/module_reopening_fix.rb
rspec-1.3.1.rc lib/spec/example/module_reopening_fix.rb
rspec-1.3.0 lib/spec/example/module_reopening_fix.rb
hubbub-0.0.11 lib/vendor/plugins/rspec/lib/spec/example/module_reopening_fix.rb
hubbub-0.0.10 lib/vendor/plugins/rspec/lib/spec/example/module_reopening_fix.rb
hubbub-0.0.9 lib/vendor/plugins/rspec/lib/spec/example/module_reopening_fix.rb
hubbub-0.0.8 lib/vendor/plugins/rspec/lib/spec/example/module_reopening_fix.rb
hubbub-0.0.6 lib/vendor/plugins/rspec/lib/spec/example/module_reopening_fix.rb
simple-templater-0.0.1.4 gems/gems/rspec-1.2.9/lib/spec/example/module_reopening_fix.rb
media-path-0.1.2 vendor/rspec/lib/spec/example/module_reopening_fix.rb
simple-templater-0.0.1.3 vendor/rspec/lib/spec/example/module_reopening_fix.rb
pupu-0.0.2.pre vendor/rspec/lib/spec/example/module_reopening_fix.rb
media-path-0.1.1.pre vendor/rspec/lib/spec/example/module_reopening_fix.rb
simple-templater-0.0.1.2 vendor/rspec/lib/spec/example/module_reopening_fix.rb
media-path-0.1.1 vendor/rspec/lib/spec/example/module_reopening_fix.rb
simple-templater-0.0.1.1 vendor/rspec/lib/spec/example/module_reopening_fix.rb
pupu-0.0.2 vendor/rspec/lib/spec/example/module_reopening_fix.rb