Class: DIDKit::Document
- Inherits:
-
Object
- Object
- DIDKit::Document
- Defined in:
- lib/didkit/document.rb
Defined Under Namespace
Classes: FormatError
Instance Attribute Summary collapse
-
#did ⇒ Object
readonly
Returns the value of attribute did.
-
#handles ⇒ Object
readonly
Returns the value of attribute handles.
-
#json ⇒ Object
readonly
Returns the value of attribute json.
-
#services ⇒ Object
readonly
Returns the value of attribute services.
Instance Method Summary collapse
- #get_verified_handle ⇒ Object
-
#initialize(did, json) ⇒ Document
constructor
A new instance of Document.
Methods included from Services
#get_service, #labeler_endpoint, #labeler_host, #pds_endpoint, #pds_host
Methods included from AtHandles
Constructor Details
#initialize(did, json) ⇒ Document
Returns a new instance of Document.
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/didkit/document.rb', line 16 def initialize(did, json) raise FormatError, "Missing id field" if json['id'].nil? raise FormatError, "Invalid id field" unless json['id'].is_a?(String) raise FormatError, "id field doesn't match expected DID" unless json['id'] == did.to_s @did = did @json = json @services = parse_services(json['service'] || []) @handles = parse_also_known_as(json['alsoKnownAs'] || []) end |
Instance Attribute Details
#did ⇒ Object (readonly)
Returns the value of attribute did.
14 15 16 |
# File 'lib/didkit/document.rb', line 14 def did @did end |
#handles ⇒ Object (readonly)
Returns the value of attribute handles.
14 15 16 |
# File 'lib/didkit/document.rb', line 14 def handles @handles end |
#json ⇒ Object (readonly)
Returns the value of attribute json.
14 15 16 |
# File 'lib/didkit/document.rb', line 14 def json @json end |
#services ⇒ Object (readonly)
Returns the value of attribute services.
14 15 16 |
# File 'lib/didkit/document.rb', line 14 def services @services end |
Instance Method Details
#get_verified_handle ⇒ Object
28 29 30 |
# File 'lib/didkit/document.rb', line 28 def get_verified_handle Resolver.new.get_verified_handle(self) end |