Method: Megam::SshKeyCollection#lookup

Defined in:
lib/megam/core/sshkey_collection.rb

#lookup(sshkeys) ⇒ Object



88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/megam/core/sshkey_collection.rb', line 88

def lookup(sshkeys)
  lookup_by = nil
  if sshkeys.kind_of?(Megam::SshKey)
  lookup_by = sshkeys.name
  elsif sshkeys.kind_of?(String)
  lookup_by = sshkeys
  else
    raise ArgumentError, "Must pass a Megam::sshkeys or String to lookup"
  end
  res =@sshkeys_by_name[lookup_by]
  unless res
    raise ArgumentError, "Cannot find a sshkeys matching #{lookup_by} (did you define it first?)"
  end
  @sshkeys[res]
end