Sha256: 0615d30a2760267a0be201a813e684a558be95e8864fbb945c2aa290b089ab2f

Contents?: true

Size: 781 Bytes

Versions: 2

Compression:

Stored size: 781 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 as_json
      {
        :json_class => self.class.name,
        :contents => contents
      }
    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

2 entries across 2 versions & 1 rubygems

Version Path
pact-1.0.15 lib/pact/something_like.rb
pact-1.0.13 lib/pact/something_like.rb