Module: LocalModel
- Defined in:
- lib/local_model.rb,
lib/local_model/version.rb,
lib/local_model/generators/initialize.rb
Defined Under Namespace
Modules: Generators, Sbx
Classes: BooleanAdapter, CSV, Collection, Configuration, DatetimeAdapter, Error, FloatAdapter, Functions, IntegerAdapter, Model, PluralizedWords, RecordInvalid, RecordNotFound, StringAdapter
Constant Summary
collapse
- VERSION =
"0.1.14"
- @@path =
"#{Dir.pwd}/tmp"
- @@namespace =
nil
Class Method Summary
collapse
Class Method Details
.config(&block) ⇒ Object
50
51
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/local_model.rb', line 50
def self.config(&block)
configuration = Configuration.new
if block_given?
yield(configuration)
end
@@path = configuration.path
@@namespace = configuration.namespace
Dir.mkdir(configuration.path) unless Dir.exist?(configuration.path)
if configuration.cleanup_on_start
db_drop
end
end
|
.db_drop ⇒ Object
43
44
45
46
47
48
|
# File 'lib/local_model.rb', line 43
def self.db_drop
Dir.foreach(@@path) do |f|
fn = File.join(@@path, f)
File.delete(fn) if f != '.' && f != '..'
end
end
|
.namespace ⇒ Object
29
30
31
32
33
34
35
36
37
|
# File 'lib/local_model.rb', line 29
def self.namespace
if @@namespace.nil?
nil
elsif @@namespace == :default || @@namespace == "default"
"LocalModel::Sbx"
else
@@namespace
end
end
|
.namespaced? ⇒ Boolean
25
26
27
|
# File 'lib/local_model.rb', line 25
def self.namespaced?
!!@@namespace
end
|
.path ⇒ Object
39
40
41
|
# File 'lib/local_model.rb', line 39
def self.path
@@path
end
|