Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jiikko/eb716d31a8f3a562050313b384cc0ef0 to your computer and use it in GitHub Desktop.
Save jiikko/eb716d31a8f3a562050313b384cc0ef0 to your computer and use it in GitHub Desktop.
module Core
  def hoge
    2
  end
end

module Wrapper
  def self.extended(base) #:nodoc:
    base.class_eval do
      include Core
    end
  end
end

class App
  extend Wrapper
end

module Wrapper2
  extend Core
end

class App2
  extend Wrapper2
end
[38] pry(main)> Wrapper2.ancestors
=> [Wrapper2, Core]

[39] pry(main)> Wrapper.ancestors
=> [Wrapper]

[40] pry(main)> App.ancestors
=> [App,
 Core,
 Wrapper,
 ActiveSupport::Dependencies::ZeitwerkIntegration::RequireDependency,
 ActiveSupport::ForkTracker::CoreExtPrivate,
 ActiveSupport::ForkTracker::CoreExt,
 ActiveSupport::ToJsonWithActiveSupportEncoder,
 Object,
 PP::ObjectMixin,
 JSON::Ext::Generator::GeneratorMethods::Object,
 ActiveSupport::Dependencies::Loadable,
 ActiveSupport::Tryable,
 ActiveSupport::ForkTracker::CoreExtPrivate,
 ActiveSupport::ForkTracker::CoreExt,
 Kernel,
 BasicObject]

[41] pry(main)> App2.ancestors
=> [App2,
 Wrapper,
 ActiveSupport::Dependencies::ZeitwerkIntegration::RequireDependency,
 ActiveSupport::ForkTracker::CoreExtPrivate,
 ActiveSupport::ForkTracker::CoreExt,
 ActiveSupport::ToJsonWithActiveSupportEncoder,
 Object,
 PP::ObjectMixin,
 JSON::Ext::Generator::GeneratorMethods::Object,
 ActiveSupport::Dependencies::Loadable,
 ActiveSupport::Tryable,
 ActiveSupport::ForkTracker::CoreExtPrivate,
 ActiveSupport::ForkTracker::CoreExt,
 Kernel,
 BasicObject]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment