Sha256: 08c58745c23fbeab467000e735a476598b1cff94e0635bade6731012e5a19f0e

Contents?: true

Size: 1.23 KB

Versions: 103

Compression:

Stored size: 1.23 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
  #
  # @!visibility private
  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

103 entries across 103 versions & 16 rubygems

Version Path
fluent-plugin-nuopenlineage-light-0.1.0 vendor/bundle/ruby/3.3.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/re_include.rb
fluent-plugin-openlineage-light-0.1.4 vendor/bundle/ruby/3.3.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/re_include.rb
fluent-plugin-openlineage-light-0.1.3 vendor/bundle/ruby/3.3.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/re_include.rb
concurrent-ruby-1.3.4 lib/concurrent-ruby/concurrent/re_include.rb
fluent-plugin-openlineage-0.1.0 vendor/bundle/ruby/3.3.0/gems/concurrent-ruby-1.3.3/lib/concurrent-ruby/concurrent/re_include.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.3.3/lib/concurrent-ruby/concurrent/re_include.rb
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/re_include.rb
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/re_include.rb
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/re_include.rb
katalyst-govuk-formbuilder-1.9.2 vendor/bundle/ruby/3.3.0/gems/concurrent-ruby-1.3.3/lib/concurrent-ruby/concurrent/re_include.rb
concurrent-ruby-1.3.3 lib/concurrent-ruby/concurrent/re_include.rb
concurrent-ruby-1.3.2 lib/concurrent-ruby/concurrent/re_include.rb
tinymce-rails-7.1.2 vendor/bundle/ruby/3.3.0/gems/concurrent-ruby-1.3.1/lib/concurrent-ruby/concurrent/re_include.rb
concurrent-ruby-1.3.1 lib/concurrent-ruby/concurrent/re_include.rb
concurrent-ruby-1.3.1.pre lib/concurrent-ruby/concurrent/re_include.rb
harbr-2.8.1 vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/re_include.rb
mlh-rubocop-config-1.0.3 vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.2.3/lib/concurrent-ruby/concurrent/re_include.rb
concurrent-ruby-1.2.3 lib/concurrent-ruby/concurrent/re_include.rb
harbr-0.2.10 vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/re_include.rb
harbr-0.2.9 vendor/bundle/ruby/3.2.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/re_include.rb