Unbound Method
UnboundMethod is a method that’s not currently attached to an instance, which means it can’t yet be called. UnboundMethod instances are created by Module methods such as instance_method and can also be created by calling unbind on a Method object.
To use an UnboundMethod, you must bind it to an object using UnboundMethod#bind(object), which returns a Method that can be called. The object must be a member of the class that the unbound method came from or a subclass of that class. You can get that class with UnboundMethod#owner. It’s pretty common to call the method immediately so the shortcut method UnboundMethod#bind_call(object, ...) is equivalent to bind(object).call(...) but with a performance improvement because it doesn’t ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access