Skip to content

Instantly share code, notes, and snippets.

@RichOrElse
Created June 15, 2021 03:48
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 RichOrElse/0bda65f0aac35110b95665723a593351 to your computer and use it in GitHub Desktop.
Save RichOrElse/0bda65f0aac35110b95665723a593351 to your computer and use it in GitHub Desktop.
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