Class: Putpaws::InfraNetworkConfig
- Inherits:
-
Struct
- Object
- Struct
- Putpaws::InfraNetworkConfig
- Defined in:
- lib/putpaws/infra_network_config.rb
Instance Attribute Summary collapse
-
#assign_public_ip ⇒ Object
Returns the value of attribute assign_public_ip.
-
#name ⇒ Object
Returns the value of attribute name.
-
#security_groups ⇒ Object
Returns the value of attribute security_groups.
-
#subnets ⇒ Object
Returns the value of attribute subnets.
Class Method Summary collapse
Instance Attribute Details
#assign_public_ip ⇒ Object
Returns the value of attribute assign_public_ip
4 5 6 |
# File 'lib/putpaws/infra_network_config.rb', line 4 def assign_public_ip @assign_public_ip end |
#name ⇒ Object
Returns the value of attribute name
4 5 6 |
# File 'lib/putpaws/infra_network_config.rb', line 4 def name @name end |
#security_groups ⇒ Object
Returns the value of attribute security_groups
4 5 6 |
# File 'lib/putpaws/infra_network_config.rb', line 4 def security_groups @security_groups end |
#subnets ⇒ Object
Returns the value of attribute subnets
4 5 6 |
# File 'lib/putpaws/infra_network_config.rb', line 4 def subnets @subnets end |
Class Method Details
.all ⇒ Object
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 |