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, #service

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 Core::DeprecatedConnectionAccessors

#connection, #connection=, #prepare_service_value

Methods included from Attributes::InstanceMethods

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

Constructor Details

#initialize(attributes) ⇒ Network

Returns a new instance of Network.



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

def initialize(attributes)
  # Old 'connection' is renamed as service and should be used instead
  prepare_service_value(attributes)
  super
end

Instance Method Details

#createObject



34
35
36
37
# File 'lib/fog/openstack/models/network/network.rb', line 34

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

#destroyObject



46
47
48
49
50
# File 'lib/fog/openstack/models/network/network.rb', line 46

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

#saveObject



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

def save
  identity ? update : create
end

#updateObject



39
40
41
42
43
44
# File 'lib/fog/openstack/models/network/network.rb', line 39

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