Class: KStor::Crypto::ArmoredHash

Inherits:
ArmoredValue show all
Defined in:
lib/kstor/crypto/keys.rb

Overview

A Hash.

Direct Known Subclasses

KDFParams

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ArmoredValue

from_binary, #initialize, #to_ascii, #to_binary

Constructor Details

This class inherits a constructor from KStor::Crypto::ArmoredValue

Class Method Details

.from_hash(hash) ⇒ Object



64
65
66
# File 'lib/kstor/crypto/keys.rb', line 64

def self.from_hash(hash)
  from_binary(hash.to_json)
end

Instance Method Details

#[](key) ⇒ Object



72
73
74
# File 'lib/kstor/crypto/keys.rb', line 72

def [](key)
  to_hash[key]
end

#[]=(key, val) ⇒ Object



76
77
78
79
80
# File 'lib/kstor/crypto/keys.rb', line 76

def []=(key, val)
  h = to_hash
  h[key] = val
  @value = ASCIIArmor.encode(h.to_json)
end

#to_hashObject



68
69
70
# File 'lib/kstor/crypto/keys.rb', line 68

def to_hash
  JSON.parse(to_binary)
end