Sha256: 3fbf2e216e5c7f881f4a7816615aa622a0233290df008fdb535ac8c517cb8f2b

Contents?: true

Size: 820 Bytes

Versions: 35

Compression:

Stored size: 820 Bytes

Contents

require 'pact/symbolize_keys'
module Pact

  # Specifies that the actual object should be considered a match if
  # it includes the same keys, and the values of the keys are of the same class.

  class SomethingLike
    include SymbolizeKeys

    attr_reader :contents

    def initialize contents
      @contents = contents
    end

    def to_hash
      {
        :json_class => self.class.name,
        :contents => contents
      }
    end

    def as_json
      to_hash
    end

    def to_json opts = {}
      as_json.to_json opts
    end

    def self.json_create hash
      new(symbolize_keys(hash)[:contents])
    end

    def eq other
      self == other
    end

    def == other
      other.is_a?(SomethingLike) && other.contents == self.contents
    end

    def generate
      contents
    end
  end
end


Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
pact-1.3.3 lib/pact/something_like.rb
pact-1.3.2 lib/pact/something_like.rb
pact-1.3.1 lib/pact/something_like.rb
pact-1.3.0 lib/pact/something_like.rb
pact-1.2.1.rc2 lib/pact/something_like.rb
pact-1.2.1.rc1 lib/pact/something_like.rb
pact-1.1.1 lib/pact/something_like.rb
pact-1.1.0 lib/pact/something_like.rb
pact-1.1.0.rc5 lib/pact/something_like.rb
pact-1.1.0.rc4 lib/pact/something_like.rb
pact-1.1.0.rc3 lib/pact/something_like.rb
pact-1.0.39 lib/pact/something_like.rb
pact-1.1.0.rc2 lib/pact/something_like.rb
pact-1.0.38 lib/pact/something_like.rb
pact-1.1.0.rc1 lib/pact/something_like.rb
pact-1.0.37 lib/pact/something_like.rb
pact-1.0.36 lib/pact/something_like.rb
pact-1.0.35 lib/pact/something_like.rb
pact-1.0.34 lib/pact/something_like.rb
pact-1.0.33 lib/pact/something_like.rb