Class: Bosh::Director::Models::Deployment

Inherits:
Object
  • Object
show all
Defined in:
lib/bosh/director/models/deployment.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.create_with_teams(attributes) ⇒ Object



28
29
30
31
32
33
# File 'lib/bosh/director/models/deployment.rb', line 28

def self.create_with_teams(attributes)
  teams = attributes.delete(:teams)
  deployment = create(attributes)
  deployment.teams = teams
  deployment
end

Instance Method Details



19
20
21
22
# File 'lib/bosh/director/models/deployment.rb', line 19

def link_spec
  result = self.link_spec_json
  result ? JSON.parse(result) : {}
end


24
25
26
# File 'lib/bosh/director/models/deployment.rb', line 24

def link_spec=(data)
  self.link_spec_json = JSON.generate(data)
end

#teams=(teams) ⇒ Object



35
36
37
38
39
40
41
42
# File 'lib/bosh/director/models/deployment.rb', line 35

def teams=(teams)
  Bosh::Director::Transactor.new.retryable_transaction(Deployment.db) do
    self.remove_all_teams
    (teams || []).each do |t|
      self.add_team(t)
    end
  end
end

#validateObject



13
14
15
16
17
# File 'lib/bosh/director/models/deployment.rb', line 13

def validate
  validates_presence :name
  validates_unique :name
  validates_format VALID_ID, :name
end