Class: Staypuft::SubnetTypingsController

Inherits:
ActionController::Base
  • Object
show all
Defined in:
app/controllers/staypuft/subnet_typings_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



3
4
5
6
7
8
9
10
11
12
13
14
# File 'app/controllers/staypuft/subnet_typings_controller.rb', line 3

def create
  @errors = {}
  @deployment = Deployment.find(params[:deployment_id])
  @subnet_type = SubnetType.find(params[:subnet_type_id])
  @subnet = Subnet.find(params[:subnet_id])
  check_for_existing_assignments
  check_for_ip_management
  check_public_api_for_default_gateway
  check_for_unsharable_subnet_types
  @subnet_typing = @deployment.subnet_typings.new(:subnet_id => @subnet.id, :subnet_type_id => @subnet_type.id)
  @saved = @errors.blank? ? @subnet_typing.save : false
end

#destroyObject



30
31
32
33
34
35
36
37
38
39
40
41
# File 'app/controllers/staypuft/subnet_typings_controller.rb', line 30

def destroy
  @errors = {}
  @subnet_typing = SubnetTyping.find(params[:id])
  @deployment = @subnet_typing.deployment
  @subnet = @subnet_typing.subnet
  check_for_existing_assignments
  @subnet_type = @subnet_typing.subnet_type
  if @subnet_type.is_required
    @errors[@subnet_type.name] = ["Network traffic type is required."]
  end
  @destroyed = @errors.blank? ? @subnet_typing.destroy : false
end

#updateObject



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/controllers/staypuft/subnet_typings_controller.rb', line 16

def update
  @errors = {}
  @subnet_typing = SubnetTyping.find(params[:id])
  @deployment = @subnet_typing.deployment
  @subnet_type = @subnet_typing.subnet_type
  @subnet = Subnet.find(params[:subnet_id])
  check_for_existing_assignments
  check_for_ip_management
  check_public_api_for_default_gateway
  check_for_unsharable_subnet_types
  @subnet_typing.subnet = @subnet
  @saved = @errors.blank? ? @subnet_typing.save : false
end