Class: DBGeni::Base
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
#apply_all_code, #apply_code, #apply_list_of_code, #apply_outstanding_code, #code, #current_code, #list_of_code, #outstanding_code, #remove_all_code, #remove_code, #remove_list_of_code
Constructor Details
permalink
#initialize(config_file) ⇒ Base
Returns a new instance of Base.
[View source]
42
43
44
45
|
# File 'lib/dbgeni/base.rb', line 42
def initialize(config_file)
load_config(config_file)
initialize_logger
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
permalink
#method_missing(meth, *args, &blk) ⇒ Object
[View source]
135
136
137
138
139
140
141
142
143
|
# File 'lib/dbgeni/base.rb', line 135
def method_missing(meth, *args, &blk)
if meth =~ /migration/
delegate_to_migration_cli(meth.intern, *args)
elsif meth =~ /dml/
delegate_to_dml_cli(meth.to_s.gsub(/dml/,'migration').intern, *args)
else
super
end
end
|
Instance Attribute Details
Returns the value of attribute config.
25
26
27
|
# File 'lib/dbgeni/base.rb', line 25
def config
@config
end
|
Class Method Details
permalink
.installer_for_environment(config_file, environment_name = nil) ⇒ Object
[View source]
32
33
34
35
36
37
38
39
40
|
# File 'lib/dbgeni/base.rb', line 32
def self.installer_for_environment(config_file, environment_name=nil)
installer = self.new(config_file)
installer.select_environment(environment_name)
installer
end
|
Instance Method Details
permalink
#connection ⇒ Object
[View source]
98
99
100
|
# File 'lib/dbgeni/base.rb', line 98
def connection
@connection ||= connect
end
|
permalink
#disconnect ⇒ Object
[View source]
91
92
93
94
95
96
|
# File 'lib/dbgeni/base.rb', line 91
def disconnect
if @connection
@connection.disconnect
end
@connection = nil
end
|
permalink
#run_plugin(hook, object, params = {}) ⇒ Object
[View source]
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
# File 'lib/dbgeni/base.rb', line 65
def run_plugin(hook, object, params={})
pdir = @config.plugin_directory
if pdir && pdir != ''
unless @plugin_manager
@plugin_manager = DBGeni::Plugin.new
@plugin_manager.load_plugins(pdir)
end
@plugin_manager.run_plugins(hook,
{
:logger => @logger,
:object => object,
:environment => @config.env,
:connection => connection
}.merge!(params)
)
end
end
|
permalink
#select_environment(environment_name) ⇒ Object
[View source]
47
48
49
50
51
52
53
54
|
# File 'lib/dbgeni/base.rb', line 47
def select_environment(environment_name)
current_environment = selected_environment_name
if current_environment != nil && current_environment != environment_name
disconnect
end
@config.set_env(environment_name)
end
|