How a macro can dynamically define a method that can be overridden with super
in the same class.
You can use the with_module_inheritance
helper below if you want. It can be handy to make parts of a
modularity
Show archive.org 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 https://thepugautomatic.com/2013/07/dsom/
module WithModuleInheritance
def with_module_inheritance(&block)
anonymous_module = Module.new
include anonymous_module
anonymous_module.module_eval &block
end
end
Module.include(WithModuleInheritance)
Posted by Henning Koch to makandra dev (2023-01-27 15:25)