module PipeRpc class BasicInterface < BasicObject wanted_methods = [:initialize, :__id__, :object_id, :__send__, :respond_to?, :method_missing] existing_methods = if ::Object.const_defined?(:MRUBY_VERSION) [:initialize, :method_missing] else [:initialize, :__id__, :__send__, :instance_eval, :instance_exec, :method_missing, :singleton_method_added, :singleton_method_removed, :singleton_method_undefined] end # Remove unwanted methods unwanted_methods = existing_methods - wanted_methods unwanted_methods.each { |m| undef_method m } # Add non-existing methods by including sorted out Kernel module to_be_added_methods = wanted_methods - existing_methods kernel = ::Kernel.dup kernel.class_eval do (instance_methods - to_be_added_methods).each{ |m| remove_method m } private_instance_methods.each{ |m| remove_method m } if respond_to? :private_instance_methods end include kernel alias send __send__ end end