Sha256: 20fe5b1ad6a6aee66c999235b03d0fda67464bd1af3cd5431f37db99e3d019fd
Contents?: true
Size: 941 Bytes
Versions: 19
Compression:
Stored size: 941 Bytes
Contents
module BMC::Monkey extend ActiveSupport::Concern class_methods do def prepend_instances(&block) m = Module.new(&block) send(:prepend, m) end def prepend_class(&block) m = Module.new(&block) singleton_class.send(:prepend, m) end def prepend_instance_method(name, &block) check_instance_method_exist!(name) m = Module.new m.send(:define_method, name, &block) send(:prepend, m) end def prepend_class_method(name, &block) check_class_method_exist!(name) m = Module.new m.send(:define_method, name, &block) singleton_class.send(:prepend, m) end def check_instance_method_exist!(name) raise "instance method `#{name}` does not exist" unless instance_methods.include?(name) end def check_class_method_exist!(name) raise "class method `#{name}` does not exist" unless methods.include?(name) end end end
Version data entries
19 entries across 19 versions & 1 rubygems