Sha256: c8c1ab064d4bc91a7eec3395a70671b68e1c50af52cf109ccb8fd95005e92b45
Contents?: true
Size: 1.39 KB
Versions: 3
Compression:
Stored size: 1.39 KB
Contents
module Sidetree module Model # DID document class. class Document attr_reader :public_keys attr_reader :services # @param [Array[Sidetree::Key]] public_keys The array of public keys. # @param [Array[Sidetree::Model::Service]] services The array of service. def initialize(public_keys: [], services: []) public_keys.each do |public_key| unless public_key.is_a?(Sidetree::Key) raise Error, "public_keys should be array of Sidetree::Key objects." end end id_set = public_keys.map(&:id) if (id_set.count - id_set.uniq.count) > 0 raise Error "Public key id has to be unique." end services.each do |service| unless service.is_a?(Sidetree::Model::Service) raise Error, "services should be array of Sidetree::Model::Service objects." end end id_set = services.map(&:id) if (id_set.count - id_set.uniq.count) > 0 raise Error "Service id has to be unique." end @public_keys = public_keys @services = services end def to_h { publicKeys: public_keys.map(&:to_h), services: services.map(&:to_h) } end # Generate replace patch. # @return [Hash] def to_replace_patch { action: OP::PatchAction::REPLACE, document: to_h } end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
sidetree-0.1.5 | lib/sidetree/model/document.rb |
sidetree-0.1.4 | lib/sidetree/model/document.rb |
sidetree-0.1.3 | lib/sidetree/model/document.rb |