Sha256: d88673ff4991277ee4b2b6e43894689f97290db75253c762395d04b49df5b714
Contents?: true
Size: 616 Bytes
Versions: 18
Compression:
Stored size: 616 Bytes
Contents
require "securerandom" module Support module MethodPatchMacro def self.included(base) base.extend ClassMethods end module ClassMethods def with_module_method(mod, meth, &block) tag = SecureRandom.hex(8) orig_meth = "_#{tag}_#{meth}".to_sym before do mod.module_eval do alias_method orig_meth, meth define_method meth, &block end end after do mod.module_eval do alias_method meth, orig_meth remove_method orig_meth end end end end end end
Version data entries
18 entries across 18 versions & 2 rubygems