Sha256: 32790ada1ed367e1e89a04c9a1735e1212e675d5a6a42f5c2342f113af7fce0e

Contents?: true

Size: 524 Bytes

Versions: 2

Compression:

Stored size: 524 Bytes

Contents

module Compact
  class ArgumentInterceptor < SimpleDelegator
    attr_accessor :invocations

    def initialize(delegate)
      @invocations = []
      @contract = nil
      super
    end

    def register(contract)
      @contract = contract
    end

    def method_missing(method, *args, &block)
      returns = super
      invocation = Invocation.new(method: method, args: args, returns: returns)
      @invocations.push(invocation)
      @contract.add_invocation(invocation) if @contract
      returns
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
compact-0.1.1 lib/compact/argument_interceptor.rb
compact-0.1.0 lib/compact/argument_interceptor.rb