Sha256: 3ea49dcd73833e1d28f49249b3662acae3d0f05e8d3b2915a56ab2a756e43045

Contents?: true

Size: 892 Bytes

Versions: 1

Compression:

Stored size: 892 Bytes

Contents

Module.class_eval do
  def dup_including(*methods)
    dup.class_eval do
      aliased = (methods.last.is_a? Hash) ? methods.last : {}
      aliased.each{ |from, to| alias_method to, from }

      to_be_kept_methods = methods + aliased.values
      (all_instance_methods - to_be_kept_methods).each{ |m| remove_method m }

      self
    end
  end

  def all_instance_methods
    private_methods = (respond_to? :private_instance_methods) ? private_instance_methods : []
    instance_methods + private_methods
  end

  if const_defined? :MRUBY_VERSION
    alias_method :simple_const_get, :const_get

    def const_get(constant_path, *args)
      if constant_path.is_a? String
        constant_path.split('::').inject(self) do |mod, constant|
          mod.simple_const_get(constant.to_sym, *args)
        end
      else
        simple_const_get(constant_path, *args)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pipe_rpc-2.5.0 lib/pipe_rpc/_pipe_rpc.rb