Sha256: 56f2500e200be024f6f76ac2a0b19be59b3ace77320e3670cba614a65119a113

Contents?: true

Size: 687 Bytes

Versions: 2

Compression:

Stored size: 687 Bytes

Contents

# frozen_string_literal: true

module Yardcheck
  class Proxy < BasicObject
    def initialize(target)
      @target = target
    end

    undef_method :==
    undef_method :!=
    undef_method :!

    def method_missing(method_name, *args, &block)
      if target_respond_to?(method_name)
        @target.__send__(method_name, *args, &block)
      else
        ::Object
          .instance_method(method_name)
          .bind(@target)
          .call(*args, &block)
      end
    end

    private

    def target_respond_to?(method_name)
      ::Object
        .instance_method(:respond_to?)
        .bind(@target)
        .call(method_name, true)
    end
  end # Proxy
end # Yardcheck

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
yardcheck-0.0.2 lib/yardcheck/proxy.rb
yardcheck-0.0.1 lib/yardcheck/proxy.rb