Class: Aspera::Keychain::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/aspera/keychain/base.rb

Constant Summary collapse

CONTENT_KEYS =
%i[label username password url description].freeze

Instance Method Summary collapse

Instance Method Details

#ids ⇒ Object

Returns a lightweight list: one Hash per secret with :label (and :id if the backend has one). Override in subclasses that can provide this cheaply without fetching full item details.



10
11
12
# File 'lib/aspera/keychain/base.rb', line 10

def ids
  all.map { |s| s.slice(:id, :label).compact }
end

#validate_set(options) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/aspera/keychain/base.rb', line 14

def validate_set(options)
  Aspera.assert_type(options, Hash) { 'options' }
  unsupported = options.keys - CONTENT_KEYS
  Aspera.assert(unsupported.empty?) { "unsupported options: #{unsupported}, use #{CONTENT_KEYS.join(', ')}" }
  options.each_pair do |k, v|
    Aspera.assert_type(v, String) { k.to_s }
  end
  Aspera.assert(options.key?(:label), 'label is required')
end