Sha256: 6c2e45d64853c8b9db33b34a5439978578d59bf4112db85f0a4047251a209843

Contents?: true

Size: 918 Bytes

Versions: 4

Compression:

Stored size: 918 Bytes

Contents

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

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

      # Create delta object from hash object.
      # @param [Hash] object
      # @return [Sidetree::Model::Delta]
      def self.from_object(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

      def ==(other)
        return false unless other.is_a?(Delta)
        to_hash == other.to_hash
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
sidetree-0.1.5 lib/sidetree/model/delta.rb
sidetree-0.1.4 lib/sidetree/model/delta.rb
sidetree-0.1.3 lib/sidetree/model/delta.rb
sidetree-0.1.2 lib/sidetree/model/delta.rb