Sha256: 087005243f4c795b6ce6885e539ce7ca4db97a385d610964a0e4036ec4d04fae

Contents?: true

Size: 830 Bytes

Versions: 110

Compression:

Stored size: 830 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 opts = {}
      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

110 entries across 110 versions & 2 rubygems

Version Path
pact-support-1.21.2 lib/pact/something_like.rb
pact-support-1.21.1 lib/pact/something_like.rb
pact-support-1.21.0 lib/pact/something_like.rb
pact-support-1.20.2 lib/pact/something_like.rb
pact-support-1.20.1 lib/pact/something_like.rb
pact-support-1.20.0 lib/pact/something_like.rb
pact-support-1.19.0 lib/pact/something_like.rb
pact-support-1.18.1 lib/pact/something_like.rb
pact-support-1.18.0 lib/pact/something_like.rb
hs-pact-support-1.17.1 lib/pact/something_like.rb
pact-support-1.17.0 lib/pact/something_like.rb
pact-support-1.16.10 lib/pact/something_like.rb
pact-support-1.16.9 lib/pact/something_like.rb
pact-support-1.16.8 lib/pact/something_like.rb
pact-support-1.16.7 lib/pact/something_like.rb
pact-support-1.16.6 lib/pact/something_like.rb
pact-support-1.16.5 lib/pact/something_like.rb
pact-support-1.16.4 lib/pact/something_like.rb
pact-support-1.16.3 lib/pact/something_like.rb
pact-support-1.16.2 lib/pact/something_like.rb