Class: Arkaan::Utils::Seeder

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/arkaan/utils/seeder.rb

Overview

This class loads the necessary data in the database if they don’t exist yet.

Author:

Instance Method Summary collapse

Instance Method Details

#create_service(key) ⇒ Arkaan::Monitoring::Service

Creates the service if it does not exist, and the instance if it does not exist.

Returns:



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/arkaan/utils/seeder.rb', line 10

def create_service(key)
  service = Arkaan::Monitoring::Service.where(key: key).first

  if service.nil?
    service = Arkaan::Monitoring::Service.create!(key: key, path: "/#{key}", premium: true, active: true)
  end

  if service.instances.where(url: ENV['SERVICE_URL']).first.nil?
    Arkaan::Monitoring::Instance.create!(url: ENV['SERVICE_URL'], running: true, service: service, active: true)
  end

  return service
end