Class: Squealer::Database

Inherits:
Object show all
Includes:
Singleton
Defined in:
lib/squealer/database.rb

Defined Under Namespace

Classes: Connection, Source

Instance Method Summary collapse

Instance Method Details

#exportObject



32
33
34
# File 'lib/squealer/database.rb', line 32

def export
  @export_do
end

#export_to(adapter, host, username, password, name) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/squealer/database.rb', line 15

def export_to(adapter, host, username, password, name)
  require "do_#{adapter}"

  @export_do.release if @export_do
  creds = ""
  creds << username if username
  creds << ":#{password}" if password
  at_host = ""
  at_host << "#{creds}@" unless creds.empty?
  at_host << host
  @export_do = DataObjects::Connection.new("#{adapter}://#{at_host}/#{name}")
end

#importObject



28
29
30
# File 'lib/squealer/database.rb', line 28

def import
  @import_connection
end

#import_from(host, port, name) ⇒ Object



10
11
12
13
# File 'lib/squealer/database.rb', line 10

def import_from(host, port, name)
  @import_dbc = Mongo::Connection.new(host, port, :slave_ok => true).db(name)
  @import_connection = Connection.new(@import_dbc)
end

#upsertable?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/squealer/database.rb', line 36

def upsertable?
  defined?(DataObjects::Mysql) && @export_do.is_a?(DataObjects::Mysql::Connection)
end