Read more

Dynamic super-overridable methods in Ruby – The Pug Automatic

Henning Koch
January 27, 2023Software engineer at makandra GmbH

How a macro can dynamically define a method that can be overridden with super in the same class.

Illustration web development

Do you need DevOps-experts?

Your development team has a full backlog? No time for infrastructure architecture? Our DevOps team is ready to support you!

  • We build reliable cloud solutions with Infrastructure as code
  • We are experts in security, Linux and databases
  • We support your dev team to perform
Read more Show snapshot

You can use the with_module_inheritance helper below if you want. It can be handy to make parts of a modularity Show snapshot trait super-able.

# ./lib/ext/module/with_module_inheritance.rb
# This macro allows you to define methods in a modularity trait that can be
# modified using the `super` keyword
# See
module WithModuleInheritance
  def with_module_inheritance(&block)
    anonymous_module =
    include anonymous_module
    anonymous_module.module_eval &block
Posted by Henning Koch to makandra dev (2023-01-27 16:25)