Sha256: 8bf6b78600f9a3ceddfd31a6cc407bd675918c7c320211fc6e0af6ad9dd556aa

Contents?: true

Size: 796 Bytes

Versions: 2

Compression:

Stored size: 796 Bytes

Contents

module Compact
  class Invocation
    attr_reader :method, :args, :returns
    def initialize( method:, args:,  returns:)
      @method = method
      @args = args
      @returns = returns
    end

    def == other_invocation
      same_returns = returns == other_invocation.returns
      matches_call(other_invocation) && same_returns
    end

    def eql? other_invocation
      self.== other_invocation
    end

    def hash
      describe.hash
    end

    def matches_call(other_invocation)
      same_args = args == other_invocation.args
      same_method = method == other_invocation.method
      same_args && same_method
    end

    def describe
      <<~DESCRIPTION
      method: #{method}
      invoke with: #{args.inspect}
      returns: #{returns}
      DESCRIPTION
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

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