Class: Arkaan::Utils::Seeder
- Inherits:
-
Object
- Object
- Arkaan::Utils::Seeder
- Includes:
- Singleton
- Defined in:
- lib/virtuaservices/utils/seeder.rb
Overview
This class loads the necessary data in the database if they don’t exist yet.
Instance Method Summary collapse
-
#create_service(key) ⇒ Arkaan::Monitoring::Service
Creates the service if it does not exist, and the instance if it does not exist.
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.
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/virtuaservices/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 |