Created
June 15, 2021 03:48
-
-
Save RichOrElse/0bda65f0aac35110b95665723a593351 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Runner | |
def initialize(**data) | |
end | |
def run(klass) | |
klass.new.process | |
end | |
def call | |
process | |
end | |
def self.included(base) | |
def base.run(klass) | |
runner = klass.new | |
define_method(:call) do | |
process | |
runner.call | |
end | |
end | |
end | |
end | |
class A | |
include Runner | |
def process | |
puts 'A' | |
{nameA: 'A'} | |
end | |
end | |
class B | |
include Runner | |
run A | |
def process | |
puts 'B' | |
{nameB: 'B'} | |
end | |
end | |
class C < B | |
def process | |
puts 'C' | |
{nameC: 'C'} | |
end | |
end | |
class D < B | |
run C | |
def process | |
puts 'D' | |
{nameD: 'D'} | |
super | |
run A | |
end | |
end | |
D.new({asd: 33}).() | |
#output there | |
# D | |
# B | |
# A | |
# C | |
# A |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment