Class: Database
- Inherits:
-
Object
- Object
- Database
- Defined in:
- lib/database.rb
Instance Attribute Summary collapse
-
#generator ⇒ Object
Returns the value of attribute generator.
-
#rails_root ⇒ Object
Returns the value of attribute rails_root.
Instance Method Summary collapse
- #connect(yaml) ⇒ Object
-
#initialize(rails_root, single, force) ⇒ Database
constructor
A new instance of Database.
- #load ⇒ Object
Constructor Details
#initialize(rails_root, single, force) ⇒ Database
Returns a new instance of Database.
5 6 7 8 9 |
# File 'lib/database.rb', line 5 def initialize(rails_root, single, force) @single = single @rails_root = rails_root @generator = Generator.new(@rails_root, single, force) end |
Instance Attribute Details
#generator ⇒ Object
Returns the value of attribute generator.
3 4 5 |
# File 'lib/database.rb', line 3 def generator @generator end |
#rails_root ⇒ Object
Returns the value of attribute rails_root.
3 4 5 |
# File 'lib/database.rb', line 3 def rails_root @rails_root end |
Instance Method Details
#connect(yaml) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/database.rb', line 17 def connect(yaml) host = yaml['development']['host'] host ||= 'localhost' ActiveRecord::Base.establish_connection(:adapter => "mysql2", :database => yaml['development']['database']) @generator.create_factories end |
#load ⇒ Object
11 12 13 14 15 |
# File 'lib/database.rb', line 11 def load file = File.join(@rails_root, 'config', 'database.yml') yaml = YAML.load_file(file) connect(yaml) end |