Module: ConventionalModels
- Defined in:
- lib/conventional_models/version.rb,
lib/conventional_models.rb,
lib/conventional_models/cli.rb,
lib/conventional_models/table.rb,
lib/conventional_models/column.rb,
lib/conventional_models/config.rb,
lib/conventional_models/options.rb,
lib/conventional_models/database.rb,
lib/conventional_models/option_parser.rb
Overview
Defined Under Namespace
Modules: VERSION
Classes: CLI, Column, Config, Database, OptionParser, Options, Table
Constant Summary
collapse
- @@database =
nil
- @@model_code =
[]
Class Method Summary
collapse
Class Method Details
20
21
22
23
24
25
26
|
# File 'lib/conventional_models.rb', line 20
def self.configure(config=nil, &block)
@@config = Config.new(&block)
@@database = Database.new(@@config)
code = @@database.code
run_code code
@@model_code << code
end
|
46
47
48
49
50
|
# File 'lib/conventional_models.rb', line 46
def self.configure_active_record(config='config/database.yml', environment='development')
config = YAML::load(IO.read(config))
ActiveRecord::Base.configurations = config
ActiveRecord::Base.establish_connection(config[environment])
end
|
.model_code ⇒ Object
32
33
34
|
# File 'lib/conventional_models.rb', line 32
def self.model_code
@@model_code.join("\n")
end
|
.model_code_for(table) ⇒ Object
36
37
38
|
# File 'lib/conventional_models.rb', line 36
def self.model_code_for(table)
@@database.code_for(table)
end
|
.run_code(code) ⇒ Object
28
29
30
|
# File 'lib/conventional_models.rb', line 28
def self.run_code(code)
eval code
end
|
.run_console! ⇒ Object
40
41
42
43
44
|
# File 'lib/conventional_models.rb', line 40
def self.run_console!
configure_active_record
configure
IRB.start
end
|