Sha256: 0b4a2c3c003779386f881a4ca27ea308da9352984c2faafa795ce348d6473bdd
Contents?: true
Size: 620 Bytes
Versions: 16
Compression:
Stored size: 620 Bytes
Contents
class Proc def bind(object) block = self object.class_eval do method_name = :__proc_rebound_method__ method = nil Thread.exclusive do method_already_exists = object.respond_to?(method_name) && instance_method(method_name).owner == self old_method = instance_method(method_name) if method_already_exists define_method(method_name, &block) method = instance_method(method_name) remove_method(method_name) define_method(method_name, old_method) if method_already_exists end method end.bind(object) end end
Version data entries
16 entries across 16 versions & 1 rubygems