Class: OpsWalrus::SecretRef

Inherits:
Object
  • Object
show all
Defined in:
lib/opswalrus/hosts_file.rb

Instance Method Summary collapse

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



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_sObject



354
355
356
# File 'lib/opswalrus/hosts_file.rb', line 354

def to_s
  @secret_name
end