Sha256: 9661747846fb9fd60678248d871b469dc1f907a5f594a72419e52a2466afe2ad

Contents?: true

Size: 685 Bytes

Versions: 1

Compression:

Stored size: 685 Bytes

Contents

module PipeRpc
  class BasicInterface < BasicObject
    def self.const_missing(name)
      ::Object.const_get(name)
    end

    wanted_methods = [:initialize, :__id__, :object_id, :__send__, :respond_to?, :method_missing]
    wanted_methods += (Object.const_defined? :MRUBY_VERSION) ? [:!] : [:!, :==, :!=, :equal?]

    existing_methods = BasicObject.all_instance_methods

    # 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
    include Kernel.dup_including *(wanted_methods - existing_methods)

    alias send __send__
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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