class SSH::Manager::Database

Constants

DATABASE

Attributes

connections[RW]

Public Class Methods

new() click to toggle source
# File lib/ssh/manager/db.rb, line 39
def initialize
  @connections = DATABASE[:connection]
end

Public Instance Methods

add_new_connection(connection) click to toggle source
# File lib/ssh/manager/db.rb, line 51
def add_new_connection(connection)
  @connections.insert(connection)
end
delete_connection(id) click to toggle source
# File lib/ssh/manager/db.rb, line 55
def delete_connection(id)
  @connections.where(:id => id).delete
end
get_connection_by_id(id) click to toggle source
# File lib/ssh/manager/db.rb, line 43
def get_connection_by_id(id)
  @connections[:id => id].to_hash
end
get_connection_data() click to toggle source
# File lib/ssh/manager/db.rb, line 47
def get_connection_data
  @connections.all
end
search_for(term) click to toggle source
# File lib/ssh/manager/db.rb, line 63
def search_for(term)
  # check online: search for 'contains' not for complete matching
  return  @connections.where(:ip => term),  @connections.where(:user => term), @connections.where(:hostname => term), @connections.where(:port => term), @connections.where(:note => term), @connections.where(:group => term), @connections.where(:options => term)
end
update_connection(connection) click to toggle source
# File lib/ssh/manager/db.rb, line 59
def update_connection(connection)
  @connections.where(:id => connection[:id]).update(connection)
end