3 ms·
Adding and/or altering functionality at runtime isn't dangerous. Monkeypatching may be, so avoid that. Also, an entirely too-little used idiom (blame Rails pro
by rue 15y ago
Adding and/or altering functionality at runtime isn't dangerous. Monkeypatching may be, so avoid that.
Also, an entirely too-little used idiom (blame Rails programmers):
module OverrideSomeMethod
def some_method
…
end
end
s = SomeClass.new
s.extend OverrideSomeMethod
s.some_method
- draegtun 15y agoThis is an idiom I use regularly (in Perl, Ruby, Io & Javascript) and come across it often in the Perl world where Moose roles are used. The only downside of this idiom is the extra runtime cost which maybe an issue for Rails?