Sha256: fbce5741a23a1cd657691d0131ce23c97f2a38a5bef8e3b79c4160f044d82384

Contents?: true

Size: 1.2 KB

Versions: 120

Compression:

Stored size: 1.2 KB

Contents

module Concurrent

  # Methods form module A included to a module B, which is already included into class C,
  # will not be visible in the C class. If this module is extended to B then A's methods
  # are correctly made visible to C.
  #
  # @example
  #   module A
  #     def a
  #       :a
  #     end
  #   end
  #
  #   module B1
  #   end
  #
  #   class C1
  #     include B1
  #   end
  #
  #   module B2
  #     extend Concurrent::ReInclude
  #   end
  #
  #   class C2
  #     include B2
  #   end
  #
  #   B1.send :include, A
  #   B2.send :include, A
  #
  #   C1.new.respond_to? :a # => false
  #   C2.new.respond_to? :a # => true
  module ReInclude
    # @!visibility private
    def included(base)
      (@re_include_to_bases ||= []) << [:include, base]
      super(base)
    end

    # @!visibility private
    def extended(base)
      (@re_include_to_bases ||= []) << [:extend, base]
      super(base)
    end

    # @!visibility private
    def include(*modules)
      result = super(*modules)
      modules.reverse.each do |module_being_included|
        (@re_include_to_bases ||= []).each do |method, mod|
          mod.send method, module_being_included
        end
      end
      result
    end
  end
end

Version data entries

120 entries across 106 versions & 25 rubygems

Version Path
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/concurrent-ruby-1.1.10/lib/concurrent-ruby/concurrent/re_include.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/concurrent-ruby-1.1.9/lib/concurrent-ruby/concurrent/re_include.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/concurrent-ruby-1.1.9/lib/concurrent-ruby/concurrent/re_include.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/concurrent-ruby-1.1.10/lib/concurrent-ruby/concurrent/re_include.rb
rubypitaya-3.12.5 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/concurrent-ruby-1.1.10/lib/concurrent-ruby/concurrent/re_include.rb
rubypitaya-3.12.4 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/concurrent-ruby-1.1.10/lib/concurrent-ruby/concurrent/re_include.rb
rubypitaya-3.12.3 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/concurrent-ruby-1.1.10/lib/concurrent-ruby/concurrent/re_include.rb
rubypitaya-3.12.2 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/concurrent-ruby-1.1.10/lib/concurrent-ruby/concurrent/re_include.rb
o-concurrent-ruby-1.1.13 lib/concurrent-ruby/concurrent/re_include.rb
o-concurrent-ruby-1.1.12 lib/concurrent-ruby/concurrent/re_include.rb
o-concurrent-ruby-1.1.11 lib/concurrent-ruby/concurrent/re_include.rb
concurrent-ruby-1.1.10 lib/concurrent-ruby/concurrent/re_include.rb
ric-0.14.2 vendor/bundle/ruby/2.7.0/gems/concurrent-ruby-1.1.9/lib/concurrent-ruby/concurrent/re_include.rb
ric-0.14.1 vendor/bundle/ruby/2.7.0/gems/concurrent-ruby-1.1.9/lib/concurrent-ruby/concurrent/re_include.rb
phillipug-foodie-0.1.0 .vendor/ruby/3.0.0/gems/concurrent-ruby-1.1.9/lib/concurrent-ruby/concurrent/re_include.rb
ric-0.14.0 vendor/bundle/ruby/2.7.0/gems/concurrent-ruby-1.1.9/lib/concurrent-ruby/concurrent/re_include.rb
vagrant-unbundled-2.2.19.0 vendor/bundle/ruby/3.0.0/gems/concurrent-ruby-1.1.9/lib/concurrent-ruby/concurrent/re_include.rb
date_n_time_picker_activeadmin-0.1.2 vendor/bundle/ruby/2.6.0/gems/concurrent-ruby-1.1.9/lib/concurrent-ruby/concurrent/re_include.rb
date_n_time_picker_activeadmin-0.1.1 vendor/bundle/ruby/2.6.0/gems/concurrent-ruby-1.1.9/lib/concurrent-ruby/concurrent/re_include.rb
vagrant-unbundled-2.2.18.0 vendor/bundle/ruby/3.0.0/gems/concurrent-ruby-1.1.9/lib/concurrent-ruby/concurrent/re_include.rb