3 ms·
method_missing is great if you're wrapping an object class Wrapper < BasicObject def initialize(obj) @obj = obj end def method_m
by quechimba 3y ago
method_missing is great if you're wrapping an object
class Wrapper < BasicObject
def initialize(obj)
@obj = obj
end
def method_missing(name, *, **, &)
::Kernel.puts "Calling #{name}"
@obj.send(name, *, **, &)
end
end
- deleted 3y ago[deleted]
- psychoslave 3y agoYou can use Delagator for that https://ruby-doc.org/stdlib-3.1.0/libdoc/delegate/rdoc/Delegator.html https://ruby-doc.org/stdlib-3.1.0/libdoc/delegate/rdoc/Deleg...