Class: Ey::Core::Client::DatabaseServer

Inherits:
Model
  • Object
show all
Extended by:
Associations
Defined in:
lib/ey-core/models/database_server.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, #to_s, #update!, #url

Instance Method Details

#destroy!Object



45
46
47
# File 'lib/ey-core/models/database_server.rb', line 45

def destroy!
  connection.requests.new(self.connection.destroy_database_server("id" => self.id).body["request"])
end

#discoverObject



53
54
55
# File 'lib/ey-core/models/database_server.rb', line 53

def discover
  connection.requests.new(connection.discover_database_server("id" => self.identity).body["request"])
end

#master?Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/ey-core/models/database_server.rb', line 49

def master?
  !replication_source
end

#save!Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/ey-core/models/database_server.rb', line 27

def save!
  requires :replication_source, :provider_id

  params = {
    "url"              => self.collection.url,
    "provider"         => self.provider_id,
    "database_server"  => {
      "replication_source" => self.replication_source_id,
    },
  }

  if new_record?
    self.connection.requests.new(self.connection.create_database_server(params).body["request"])
  else
    raise NotImplementedError
  end
end