Class: Sidetree::Model::Delta

Inherits:
Object
  • Object
show all
Defined in:
lib/sidetree/model/delta.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(patches, update_commitment) ⇒ Delta

Initializer

Parameters:

  • patches (Array[Hash])
  • update_commitment (String)

Raises:



10
11
12
13
# File 'lib/sidetree/model/delta.rb', line 10

def initialize(patches, update_commitment)
  @patches = patches
  @update_commitment = update_commitment
end

Instance Attribute Details

#patchesObject (readonly)

Returns the value of attribute patches.



4
5
6
# File 'lib/sidetree/model/delta.rb', line 4

def patches
  @patches
end

#update_commitmentObject (readonly)

Returns the value of attribute update_commitment.



4
5
6
# File 'lib/sidetree/model/delta.rb', line 4

def update_commitment
  @update_commitment
end

Class Method Details

.from_object(object) ⇒ Sidetree::Model::Delta

Create delta object from hash object.

Parameters:

  • object (Hash)

Returns:



18
19
20
21
# File 'lib/sidetree/model/delta.rb', line 18

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

Instance Method Details

#==(other) ⇒ Object



31
32
33
34
# File 'lib/sidetree/model/delta.rb', line 31

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

#to_hObject



23
24
25
# File 'lib/sidetree/model/delta.rb', line 23

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

#to_hashObject



27
28
29
# File 'lib/sidetree/model/delta.rb', line 27

def to_hash
  Sidetree.to_hash(to_h)
end