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-0.1.4 lib/pact/something_like.rb
pact-support-0.2.0 lib/pact/something_like.rb
pact-support-0.1.3 lib/pact/something_like.rb
pact-support-0.1.2 lib/pact/something_like.rb
pact-support-0.1.1 lib/pact/something_like.rb
pact-support-0.1.0 lib/pact/something_like.rb
pact-support-0.0.4 lib/pact/something_like.rb
pact-support-0.0.3 lib/pact/something_like.rb
pact-support-0.0.2 lib/pact/something_like.rb
pact-support-0.0.1 lib/pact/something_like.rb