Sha256: 59be928dc52c0936156eb08d9f6dfbd89ebf2d0042af119687149d360348651a

Contents?: true

Size: 914 Bytes

Versions: 4

Compression:

Stored size: 914 Bytes

Contents

require 'pact_broker/deployments/environment'
require 'securerandom'

module PactBroker
  module Deployments
    module EnvironmentService

      def self.next_uuid
        SecureRandom.uuid
      end

      def self.create(uuid, environment)
        environment.uuid = uuid
        environment.save
      end

      def self.update(uuid, environment)
        environment.uuid = uuid
        environment.upsert
      end

      def self.find_all
        PactBroker::Deployments::Environment.order(Sequel.function(:lower, :display_name)).all
      end

      def self.find(uuid)
        PactBroker::Deployments::Environment.where(uuid: uuid).single_record
      end

      def self.find_by_name(name)
        PactBroker::Deployments::Environment.where(name: name).single_record
      end

      def self.delete(uuid)
        PactBroker::Deployments::Environment.where(uuid: uuid).delete
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
pact_broker-2.79.1 lib/pact_broker/deployments/environment_service.rb
pact_broker-2.79.0 lib/pact_broker/deployments/environment_service.rb
pact_broker-2.78.1 lib/pact_broker/deployments/environment_service.rb
pact_broker-2.78.0 lib/pact_broker/deployments/environment_service.rb