Class: Fog::Network::OpenStack::Network

Inherits:
Model
  • Object
show all
Defined in:
lib/fog/openstack/models/network/network.rb

Instance Attribute Summary

Attributes inherited from Model

#collection, #connection

Instance Method Summary collapse

Methods inherited from Model

#inspect, #reload, #symbolize_keys, #to_json, #wait_for

Methods included from Attributes::ClassMethods

#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes

Methods included from Attributes::InstanceMethods

#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #requires, #requires_one

Constructor Details

#initialize(attributes) ⇒ Network

Returns a new instance of Network.



16
17
18
19
# File 'lib/fog/openstack/models/network/network.rb', line 16

def initialize(attributes)
  @connection = attributes[:connection]
  super
end

Instance Method Details

#createObject



25
26
27
28
# File 'lib/fog/openstack/models/network/network.rb', line 25

def create
  merge_attributes(connection.create_network(self.attributes).body['network'])
  self
end

#destroyObject



37
38
39
40
41
# File 'lib/fog/openstack/models/network/network.rb', line 37

def destroy
  requires :id
  connection.delete_network(self.id)
  true
end

#saveObject



21
22
23
# File 'lib/fog/openstack/models/network/network.rb', line 21

def save
  identity ? update : create
end

#updateObject



30
31
32
33
34
35
# File 'lib/fog/openstack/models/network/network.rb', line 30

def update
  requires :id
  merge_attributes(connection.update_network(self.id,
                                             self.attributes).body['network'])
  self
end