Class: OpsWalrus::PublicKey
- Inherits:
-
Object
- Object
- OpsWalrus::PublicKey
- Defined in:
- lib/opswalrus/hosts_file.rb
Instance Method Summary collapse
-
#encode_with(coder) ⇒ Object
#init_with and #encode_with are demonstrated here: - djellemah.com/blog/2014/07/23/yaml-deserialisation/ - stackoverflow.com/questions/10629209/how-can-i-control-which-fields-to-serialize-with-yaml - github.com/protocolbuffers/protobuf/issues/4391 serialise to yaml.
-
#init_with(coder) ⇒ Object
deserialise from yaml.
-
#initialize(id_name, public_key) ⇒ PublicKey
constructor
yaml_tag nil.
- #key ⇒ Object
Constructor Details
#initialize(id_name, public_key) ⇒ PublicKey
yaml_tag nil
198 199 200 201 |
# File 'lib/opswalrus/hosts_file.rb', line 198 def initialize(id_name, public_key) @id = id_name @public_key = public_key end |
Instance Method Details
#encode_with(coder) ⇒ Object
#init_with and #encode_with are demonstrated here:
serialise to yaml
212 213 214 215 216 217 218 |
# File 'lib/opswalrus/hosts_file.rb', line 212 def encode_with(coder) # per https://rubydoc.info/stdlib/psych/3.0.0/Psych/Coder#scalar-instance_method coder.represent_scalar(nil, @public_key) # coder.scalar = @public_key # coder['public_key'] = @public_key end |
#init_with(coder) ⇒ Object
deserialise from yaml
221 222 223 224 |
# File 'lib/opswalrus/hosts_file.rb', line 221 def init_with(coder) @public_key = coder.scalar # @public_key = coder['public_key'] end |
#key ⇒ Object
203 204 205 |
# File 'lib/opswalrus/hosts_file.rb', line 203 def key @public_key end |