Class: Staypuft::SimpleSubnet
- Inherits:
-
Object
- Object
- Staypuft::SimpleSubnet
- Extended by:
- ActiveModel::Naming
- Includes:
- ActiveModel::AttributeMethods, ActiveModel::Validations
- Defined in:
- app/models/staypuft/simple_subnet.rb
Constant Summary collapse
- DHCP_SERVER_TYPE =
{ 'external' => 'External DHCP', 'none' => 'No existing DHCP' }
- ATTRS =
[:name, :dhcp_server, :network_address, :vlan, :gateway, :ip_range_from, :ip_range_to]
Instance Attribute Summary collapse
-
#deployment ⇒ Object
Returns the value of attribute deployment.
-
#subnet ⇒ Object
Returns the value of attribute subnet.
Instance Method Summary collapse
-
#initialize(attrs = {}) ⇒ SimpleSubnet
constructor
A new instance of SimpleSubnet.
- #save ⇒ Object
Constructor Details
#initialize(attrs = {}) ⇒ SimpleSubnet
Returns a new instance of SimpleSubnet.
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/models/staypuft/simple_subnet.rb', line 26 def initialize(attrs={}) self.dhcp_server = 'external' if attrs.is_a?(::Subnet) @subnet = Subnet.find_by_name(attrs.name) convert_attributes_from else @subnet = Subnet.new ATTRS.each do |attr| self.send("#{attr}=", attrs.has_key?(attr) ? attrs[attr] : nil) end end end |
Instance Attribute Details
#deployment ⇒ Object
Returns the value of attribute deployment.
16 17 18 |
# File 'app/models/staypuft/simple_subnet.rb', line 16 def deployment @deployment end |
#subnet ⇒ Object
Returns the value of attribute subnet.
16 17 18 |
# File 'app/models/staypuft/simple_subnet.rb', line 16 def subnet @subnet end |
Instance Method Details
#save ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'app/models/staypuft/simple_subnet.rb', line 39 def save if self.valid? @subnet = Subnet.find_or_initialize_by_name(name) convert_attributes_to @subnet.save else false end end |