Sha256: ef7f7805f3ecdd24bce0977748f491f92a98ca2342df85759139b7dec3dd0791

Contents?: true

Size: 665 Bytes

Versions: 2

Compression:

Stored size: 665 Bytes

Contents

module Sidetree
  module Model
    class Delta
      attr_reader :patches, :update_commitment

      # @param [Array[Hash]] patches
      # @param [String] update_commitment
      # @raise [Sidetree::Error]
      def initialize(patches, update_commitment)
        @patches = patches
        @update_commitment = update_commitment
      end

      def self.parse(object)
        Sidetree::Validator.validate_delta!(object)
        Delta.new(object[:patches], object[:updateCommitment])
      end

      def to_h
        { patches: patches, updateCommitment: update_commitment }
      end

      def to_hash
        Sidetree.to_hash(to_h)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sidetree-0.1.1 lib/sidetree/model/delta.rb
sidetree-0.1.0 lib/sidetree/model/delta.rb