Class: Omniscient::Adapter::MySQL
- Inherits:
-
Object
- Object
- Omniscient::Adapter::MySQL
show all
- Defined in:
- lib/omniscient/adapters/mysql.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(config) ⇒ MySQL
Returns a new instance of MySQL.
5
6
7
|
# File 'lib/omniscient/adapters/mysql.rb', line 5
def initialize( config )
@attributes = config
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/omniscient/adapters/mysql.rb', line 9
def method_missing( name, *args, &block )
if args.empty? && block.nil?
if @attributes.has_key?(name.to_s)
@attributes[name.to_s]
elsif @attributes.has_key?(name.to_sym)
@attributes[name.to_sym]
else
nil
end
else
nil
end
end
|
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
4
5
6
|
# File 'lib/omniscient/adapters/mysql.rb', line 4
def attributes
@attributes
end
|
Instance Method Details
#access_statements ⇒ Object
28
29
30
31
32
33
34
|
# File 'lib/omniscient/adapters/mysql.rb', line 28
def access_statements
str = ''
str << ' -u '+self.user unless self.user.nil?
str << ' -p'+self.password unless self.password.empty?
str << ' '+self.database unless self.database.nil?
str
end
|
#dump ⇒ Object
36
37
38
39
40
41
42
43
44
|
# File 'lib/omniscient/adapters/mysql.rb', line 36
def dump
return false unless valid_configuration?
str = 'mysqldump'
str << access_statements
str << ' '+self.table unless self.database.nil? || self.table.nil?
str << ' --single-transaction'
str << ' > .omni_dump.sql'
str
end
|
#import ⇒ Object
46
47
48
49
50
51
52
|
# File 'lib/omniscient/adapters/mysql.rb', line 46
def import
return false unless valid_configuration?
str = 'mysql'
str << access_statements
str << ' < '+Omniscient::DUMP_LOCAL_PATH
str
end
|
#valid_configuration? ⇒ Boolean
23
24
25
26
|
# File 'lib/omniscient/adapters/mysql.rb', line 23
def valid_configuration?
return false unless database && user
true
end
|