Sha256: 24c89c158c75d8d9cb1d4cc154e509c433e88ee508f31bbf932676694b0be6fe
Contents?: true
Size: 934 Bytes
Versions: 5
Compression:
Stored size: 934 Bytes
Contents
module DeepCover # Helps redefine methods in overriden_modules. # For each methods in Mod, this defines `<method>_with{out}_deep_cover`. # Set `active` to true or false to alias <method> to one or the other. module ModuleOverride attr_reader :overriden_modules def active=(active) each do |mod, method_name| mod.send :alias_method, method_name, :"#{method_name}_#{active ? 'with' : 'without'}_deep_cover" end end def override(*modules) @overriden_modules = modules each do |mod, method_name| mod.send :alias_method, :"#{method_name}_without_deep_cover", method_name mod.send :define_method, :"#{method_name}_with_deep_cover", instance_method(method_name) end end def each(&block) overriden_modules.each do |mod| instance_methods(false).each do |method_name| yield mod, method_name end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems