Sha256: 9ae1e8f26a8da46f73ee12952b47de3885efb417172dc92bd73ea773914c68f2

Contents?: true

Size: 479 Bytes

Versions: 12

Compression:

Stored size: 479 Bytes

Contents

module Bogus
  module ProxiesMethodCalls
    def proxy(method_name)
      MethodCallProxy.new do |name, *args, &return_value|
        __send__(method_name, name, *args, &return_value)
      end
    end
  end

  class MethodCallProxy < BasicObject
    def initialize(&on_called)
      @on_called = on_called
    end

    def raise(*args)
      ::Kernel.raise(*args)
    end

    def method_missing(name, *args, &block)
      @on_called.call(name, *args, &block)
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
bogus-0.1.7 lib/bogus/proxies_method_calls.rb
bogus-0.1.6 lib/bogus/proxies_method_calls.rb
bogus-0.1.5 lib/bogus/proxies_method_calls.rb
bogus-0.1.4 lib/bogus/proxies_method_calls.rb
bogus-0.1.3 lib/bogus/proxies_method_calls.rb
bogus-0.1.2 lib/bogus/proxies_method_calls.rb
bogus-0.1.1 lib/bogus/proxies_method_calls.rb
bogus-0.1.0 lib/bogus/proxies_method_calls.rb
bogus-0.0.4 lib/bogus/proxies_method_calls.rb
bogus-0.0.3 lib/bogus/proxies_method_calls.rb
bogus-0.0.3.rc.2 lib/bogus/proxies_method_calls.rb
bogus-0.0.3.rc.1 lib/bogus/proxies_method_calls.rb