Class: Putpaws::InfraNetworkConfig

Inherits:
Struct
  • Object
show all
Defined in:
lib/putpaws/infra_network_config.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#assign_public_ipObject

Returns the value of attribute assign_public_ip

Returns:

  • (Object)

    the current value of assign_public_ip



4
5
6
# File 'lib/putpaws/infra_network_config.rb', line 4

def assign_public_ip
  @assign_public_ip
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



4
5
6
# File 'lib/putpaws/infra_network_config.rb', line 4

def name
  @name
end

#security_groupsObject

Returns the value of attribute security_groups

Returns:

  • (Object)

    the current value of security_groups



4
5
6
# File 'lib/putpaws/infra_network_config.rb', line 4

def security_groups
  @security_groups
end

#subnetsObject

Returns the value of attribute subnets

Returns:

  • (Object)

    the current value of subnets



4
5
6
# File 'lib/putpaws/infra_network_config.rb', line 4

def subnets
  @subnets
end

Class Method Details

.allObject



17
18
19
20
21
22
# File 'lib/putpaws/infra_network_config.rb', line 17

def self.all
  load.map{|k,v|
    data = v.slice(*self.members)
    new(data.merge(name: k.to_s))
  }
end

.find(name) ⇒ Object



24
25
26
27
28
29
30
# File 'lib/putpaws/infra_network_config.rb', line 24

def self.find(name)
  infra_network_data = load
  data = infra_network_data[name.to_sym]
  return nil unless data
  data = data.slice(*self.members)
  new(data.merge({name: name.to_s}))
end

.load(path_prefix: '.putpaws') ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'lib/putpaws/infra_network_config.rb', line 7

def self.load(path_prefix: '.putpaws')
  @infra_network_data ||= begin
    path = Pathname.new(path_prefix).join("infra.json").to_s
    data = File.exist?(path) ?
      JSON.parse(File.read(path), symbolize_names: true).to_h :
      {}
    data[:network] || {}
  end
end