Sha256: bab0137047cf0bf00b163fad548e3e1145cb098c980fae7ee8b308269aa2a27f

Contents?: true

Size: 991 Bytes

Versions: 1

Compression:

Stored size: 991 Bytes

Contents

module PipeRpc
  class BasicInterface < BasicObject
    wanted_methods = [:initialize, :__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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pipe_rpc-2.1.0 lib/pipe_rpc/basic_interface.rb