Class: ConfigOMat::LoadedSecret

Inherits:
ConfigItem show all
Defined in:
lib/config_o_mat/shared/types.rb

Instance Attribute Summary collapse

Attributes inherited from ConfigItem

#errors

Instance Method Summary collapse

Methods inherited from ConfigItem

#==, #error, #errors?, #validate!

Constructor Details

#initialize(name, secret_id, version_id, secret_string, content_type) ⇒ LoadedSecret

Returns a new instance of LoadedSecret.



421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
# File 'lib/config_o_mat/shared/types.rb', line 421

def initialize(name, secret_id, version_id, secret_string, content_type)
  @name = name
  @secret_id = secret_id
  @version_id = version_id

  begin
    @contents = LoadedAppconfigProfile::PARSERS[content_type].call(secret_string)
    if @contents.kind_of?(Hash)
      @contents.default_proc = proc do |hash, key|
        raise KeyError.new("No key #{key.inspect} in secret #{name}", key: key, receiver: hash)
      end
    end
  rescue StandardError => e
    error :contents, e
  end
end

Instance Attribute Details

#contentsObject (readonly)

Returns the value of attribute contents.



419
420
421
# File 'lib/config_o_mat/shared/types.rb', line 419

def contents
  @contents
end

#nameObject (readonly)

Returns the value of attribute name.



419
420
421
# File 'lib/config_o_mat/shared/types.rb', line 419

def name
  @name
end

#secret_idObject (readonly)

Returns the value of attribute secret_id.



419
420
421
# File 'lib/config_o_mat/shared/types.rb', line 419

def secret_id
  @secret_id
end

#version_idObject (readonly)

Returns the value of attribute version_id.



419
420
421
# File 'lib/config_o_mat/shared/types.rb', line 419

def version_id
  @version_id
end

Instance Method Details

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


447
448
449
450
451
452
453
454
455
456
# File 'lib/config_o_mat/shared/types.rb', line 447

def eql?(other)
  return false if !super(other)
  if other.name != name ||
     other.secret_id != secret_id ||
     other.version_id != version_id ||
     other.contents != contents
    return false
  end
  true
end

#hashObject



443
444
445
# File 'lib/config_o_mat/shared/types.rb', line 443

def hash
  @name.hash ^ @secret_id.hash ^ @version_id.hash ^ @contents.hash
end

#validateObject



438
439
440
441
# File 'lib/config_o_mat/shared/types.rb', line 438

def validate
  # Since name and version_id are coming from AWS and must be present, I'm not going to check
  # them here.
end