Module: PactBroker::Deployments::EnvironmentService

Extended by:
EnvironmentService, Repositories::Scopes
Included in:
EnvironmentService
Defined in:
lib/pact_broker/deployments/environment_service.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Repositories::Scopes

scope_for, unscoped, with_no_scope

Class Method Details

.included(base) ⇒ Object



15
16
17
# File 'lib/pact_broker/deployments/environment_service.rb', line 15

def self.included(base)
  base.extend(self)
end

Instance Method Details

#create(uuid, environment) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/pact_broker/deployments/environment_service.rb', line 23

def create(uuid, environment)
  environment.uuid = uuid
  if environment.display_name.blank?
    environment.display_name = PactBroker::Pacticipants::GenerateDisplayName.call(environment.name)
  end
  environment.save
end

#delete(uuid) ⇒ Object



53
54
55
# File 'lib/pact_broker/deployments/environment_service.rb', line 53

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

#find(uuid) ⇒ Object



45
46
47
# File 'lib/pact_broker/deployments/environment_service.rb', line 45

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

#find_allObject



41
42
43
# File 'lib/pact_broker/deployments/environment_service.rb', line 41

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

#find_by_name(name) ⇒ Object



49
50
51
# File 'lib/pact_broker/deployments/environment_service.rb', line 49

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

#find_for_pacticipant(_pacticipant) ⇒ Object



57
58
59
# File 'lib/pact_broker/deployments/environment_service.rb', line 57

def find_for_pacticipant(_pacticipant)
  find_all
end

#next_uuidObject



19
20
21
# File 'lib/pact_broker/deployments/environment_service.rb', line 19

def next_uuid
  SecureRandom.uuid
end

#replace(uuid, environment) ⇒ Object Also known as: update



31
32
33
34
35
36
37
# File 'lib/pact_broker/deployments/environment_service.rb', line 31

def replace(uuid, environment)
  environment.uuid = uuid
  if environment.display_name.blank?
    environment.display_name = PactBroker::Pacticipants::GenerateDisplayName.call(environment.name)
  end
  environment.upsert
end