class Database

Public Instance Methods

postgres_url() click to toggle source
# File natural-backend/app/models/database.rb, line 15
def postgres_url
        "postgres://#{project.db_username}:#{project.db_password}@#{self.server_public_ip}/#{database_identifier}"
end
server_public_ip() click to toggle source

REFACTOR: ServerInfo Service object

# File natural-backend/app/models/database.rb, line 20
def server_public_ip
      Socket.ip_address_list.detect { |intf| intf.ipv4? and !intf.ipv4_loopback? and !intf.ipv4_multicast? and !intf.ipv4_private? }.try(:ip_address)
end

Private Instance Methods

generate_database_identifier() click to toggle source
# File natural-backend/app/models/database.rb, line 26
def generate_database_identifier
  write_attribute(:database_identifier, SecureRandom.uuid)
end
trigger_db_creation() click to toggle source
# File natural-backend/app/models/database.rb, line 30
def trigger_db_creation
  CreateDatabaseJob.perform_later(self)
end
trigger_db_destruction() click to toggle source
# File natural-backend/app/models/database.rb, line 34
def trigger_db_destruction
  DestroyDatabaseJob.perform_later(self.database_identifier)
end