I write the same function repeatedly in my classes. Is there a way to declare a function once, and just reference the function declaration in each relevant class to have it become part of the class? I want to do something like:
def add_func
expand self.new_func
puts "hello"
end
end
class A
import "add_func"
end
A.new_func
# >> hello world
I'm looking to make a class method, not an instance method, but I'd be interested in knowing how to do both. What is the Ruby construct I am looking for?