Class: OpsWalrus::SecretRef
- Inherits:
-
Object
- Object
- OpsWalrus::SecretRef
- 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(secret_name) ⇒ SecretRef
constructor
A new instance of SecretRef.
- #to_s ⇒ Object
Constructor Details
#initialize(secret_name) ⇒ SecretRef
Returns a new instance of SecretRef.
318 319 320 |
# File 'lib/opswalrus/hosts_file.rb', line 318 def initialize(secret_name) @secret_name = secret_name end |
Instance Method Details
#encode_with(coder) ⇒ Object
#init_with and #encode_with are demonstrated here:
serialise to yaml
327 328 329 330 331 332 333 334 335 336 337 338 339 340 |
# File 'lib/opswalrus/hosts_file.rb', line 327 def encode_with(coder) # The following line seems to have the effect of quoting the @secret_name # coder.style = Psych::Nodes::Mapping::FLOW if @secret_name # don't set tag explicitly, let Psych figure it out from yaml_tag # coder.represent_scalar '!days', days.first coder.scalar = @secret_name # else # # don't set tag explicitly, let Psych figure it out from yaml_tag # # coder.represent_seq '!days', days.to_a # coder.seq = @secret_name end end |
#init_with(coder) ⇒ Object
deserialise from yaml
343 344 345 346 347 348 349 350 351 352 |
# File 'lib/opswalrus/hosts_file.rb', line 343 def init_with(coder) case coder.type when :scalar @secret_name = coder.scalar # when :seq # @secret_name = coder.seq else raise "Dunno how to handle #{coder.type} for #{coder.inspect}" end end |
#to_s ⇒ Object
354 355 356 |
# File 'lib/opswalrus/hosts_file.rb', line 354 def to_s @secret_name end |