Module: Ca::DataStore::Ar
- Includes:
- TR::CondUtils, TeLogger::TeLogHelper
- Defined in:
- lib/ca/data_store/ar.rb,
lib/ca/data_store/ar/version.rb,
lib/ca/data_store/ar/provider.rb,
lib/ca/data_store/ar/model_base.rb,
lib/ca/data_store/ar/console_helper.rb,
lib/ca/data_store/ar/migration/migration_helper.rb
Defined Under Namespace
Modules: ConsoleHelper, MigrationHelper
Classes: Error, MigrateError, Model, Provider
Constant Summary
collapse
- VERSION =
"0.1.1"
Class Method Summary
collapse
Class Method Details
.connect_database(confPath = "./config/database.yml") ⇒ Object
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
# File 'lib/ca/data_store/ar.rb', line 48
def Ar.connect_database(confPath = "./config/database.yml")
teLogger.debug "Root : #{root}"
if not_empty?(root)
railsConf = File.join(root, "config","database.yml")
if File.exist?(railsConf)
path = File.expand_path(railsConf)
else
path = File.expand_path(confPath)
end
else
path = File.expand_path(confPath)
end
if File.exist?(path)
File.open(path,"r") do |f|
@conf = YAML.load(f.read)
end
ActiveRecord::Base.establish_connection(@conf["development"])
else
teLogger.warn "Skipped ActiveRecord connection since config file not available"
end
end
|
.load_model(path) ⇒ Object
41
42
43
44
45
46
|
# File 'lib/ca/data_store/ar.rb', line 41
def Ar.load_model(path)
mpath = File.expand_path(path)
Dir.glob(File.join(mpath,"*.rb")) do |m|
require m
end
end
|
.load_tasks ⇒ Object
34
35
36
37
38
39
|
# File 'lib/ca/data_store/ar.rb', line 34
def Ar.load_tasks
Dir.glob(File.join(File.dirname(__FILE__),"..","..","..","tasks","*.rake")) do |rf|
fp = File.expand_path(rf)
load fp
end
end
|
.migration_path ⇒ Object
77
78
79
|
# File 'lib/ca/data_store/ar.rb', line 77
def Ar.migration_path
File.join(File.dirname(__FILE__),"..","..","..","db","migrate")
end
|
.root ⇒ Object
85
86
87
88
|
# File 'lib/ca/data_store/ar.rb', line 85
def Ar.root
@arRoot = "." if is_empty?(@arRoot)
@arRoot
end
|
.root=(root) ⇒ Object
81
82
83
|
# File 'lib/ca/data_store/ar.rb', line 81
def Ar.root=(root)
@arRoot = root
end
|
.show_log(out = nil) ⇒ Object
73
74
75
|
# File 'lib/ca/data_store/ar.rb', line 73
def Ar.show_log(out = nil)
ActiveRecord::Base.logger = TeLogger::Tlogger.new(out)
end
|