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

unscoped, with_no_scope

Class Method Details

.included(base) ⇒ Object



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

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

Instance Method Details

#create(uuid, environment) ⇒ Object



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

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



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

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

#find(uuid) ⇒ Object



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

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

#find_allObject



38
39
40
# File 'lib/pact_broker/deployments/environment_service.rb', line 38

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

#find_by_name(name) ⇒ Object



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

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

#find_for_pacticipant(_pacticipant) ⇒ Object



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

def find_for_pacticipant(_pacticipant)
  find_all
end

#next_uuidObject



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

def next_uuid
  SecureRandom.uuid
end

#replace(uuid, environment) ⇒ Object



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

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

#scope_for(scope) ⇒ Object



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

def scope_for(scope)
  PactBroker.policy_scope!(scope)
end