Reputation: 3
Let's say I have:
module Something
class SomethingElse
def initialize(args)
@args = args
end
def some_method
#stuff
end
end
end
Is there a way I can get some_method to run automatically right after intialize, but without calling some_method from within the initialize method?
Upvotes: 0
Views: 492
Reputation: 168249
Yes, if you allow to also define initialize
in another module.
module Child
def initialize
super
# ... some_method_stuff
end
end
Something.prepend Child
Upvotes: 2