Class: Ey::Core::Client::Address

Inherits:
Model
  • Object
show all
Extended by:
Associations
Defined in:
lib/vendor/core/ey-core/models/address.rb

Instance Method Summary collapse

Methods included from Associations

assoc_accessor, assoc_coverage, assoc_reader, assoc_writer, associations, collection_reader

Methods inherited from Model

#destroy, range_parser, #save, #update!, #url

Instance Method Details

#attach(server) ⇒ Object



22
23
24
25
26
27
28
29
# File 'lib/vendor/core/ey-core/models/address.rb', line 22

def attach(server)
  params = {
    "id"     => self.identity,
    "server" => server.identity,
  }

  self.connection.requests.new(self.connection.attach_address(params).body["request"])
end

#detachObject



14
15
16
17
18
19
20
# File 'lib/vendor/core/ey-core/models/address.rb', line 14

def detach
  params = {
    "id" => self.identity,
  }

  self.connection.requests.new(self.connection.detach_address(params).body["request"])
end

#save!Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/vendor/core/ey-core/models/address.rb', line 31

def save!
  if new_record?
    requires :provider_id, :location

    params = {
      "provider" => self.provider_id,
      "address"  => {
        "location" => self.location,
      },
    }

    self.connection.requests.new(self.connection.create_address(params).body["request"])
  else raise NotImplementedError
  end
end