Module: ReloaderInterceptor::Wrapper::DSL
- Defined in:
- lib/reloader_interceptor/wrapper.rb
Instance Method Summary collapse
- #define_instance_methods_using_class_name(dst, src) ⇒ Object
- #define_singleton_methods_using_class_name(dst, src) ⇒ Object
Instance Method Details
#define_instance_methods_using_class_name(dst, src) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/reloader_interceptor/wrapper.rb', line 31 def define_instance_methods_using_class_name(dst, src) src_name = src.name public_methods = src.public_instance_methods(false) protected_methods = src.protected_instance_methods(false) private_methods = src.private_instance_methods(false) [*public_methods, *protected_methods, *private_methods].each do |method| dst.define_method method do |*args| klass = src_name.constantize klass.new(*@options).send(method, *args) end end dst.send(:protected, *protected_methods) if protected_methods.size > 0 dst.send(:private, *private_methods) if private_methods.size > 0 end |
#define_singleton_methods_using_class_name(dst, src) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/reloader_interceptor/wrapper.rb', line 8 def define_singleton_methods_using_class_name(dst, src) src_name = src.name src_singleton_class = src.singleton_class dst_singleton_class = dst.singleton_class public_methods = src_singleton_class.public_instance_methods(false) protected_methods = src_singleton_class.protected_instance_methods(false) private_methods = src_singleton_class.private_instance_methods(false) [*public_methods, *protected_methods, *private_methods].each do |method| dst_singleton_class.define_method method do |*args| klass = src_name.constantize klass.send(method, *args) end end dst_singleton_class.send(:protected, *protected_methods) if protected_methods.size > 0 dst_singleton_class.send(:private, *private_methods) if private_methods.size > 0 end |