Created
April 14, 2022 20:02
-
-
Save jkeam/ddc5fca16816be645b2c73b88c29b5ee to your computer and use it in GitHub Desktop.
Quick demonstration on how to create temporary anonymous classes as well as how to extend them
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
# encoding: UTF-8 | |
# frozen_string_literal: true | |
Metric = Class.new do | |
def destroy | |
puts 'Metric destroyed' | |
end | |
end | |
MetricWithFiber = Class.new(Metric) do | |
def destroy | |
super | |
puts 'MetricWithFiber destroyed' | |
end | |
end | |
instance = MetricWithFiber.new | |
instance.destroy |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Running this:
produces: