let's need change functionality of ruby gem need in rails project. place content of ruby gem inside main project.
is possible? there alternative methods?
thank you
you can "monkeypatching" specific methods. need create initializer overwrites method want modify. examplke create config/initializers/monkeypatch.rb
, overwrite method:
class string def inspect puts "im monkeypatched!" end end
when create string , call inspect youll see method has been patched. should careful using monkeypatching because can have unwanted sideeffects, especally when patch basic classes string or fixnum class.
Comments
Post a Comment