Class: DB

Inherits:
Object
  • Object
show all
Defined in:
lib/db.rb

Defined Under Namespace

Classes: Environment

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app_name) ⇒ DB

Returns a new instance of DB.



61
62
63
64
65
66
# File 'lib/db.rb', line 61

def initialize app_name
  @development = Environment.new 'development'
  @test = Environment.new 'test'
  @production = Environment.new 'production'
  @app_name = app_name
end

Instance Attribute Details

#developmentObject (readonly)

Returns the value of attribute development.



24
25
26
# File 'lib/db.rb', line 24

def development
  @development
end

#productionObject (readonly)

Returns the value of attribute production.



24
25
26
# File 'lib/db.rb', line 24

def production
  @production
end

#testObject (readonly)

Returns the value of attribute test.



24
25
26
# File 'lib/db.rb', line 24

def test
  @test
end

Instance Method Details

#createObject



73
74
75
# File 'lib/db.rb', line 73

def create
  `cd #{@app_name}; rake db:create`
end

#migrateObject



76
77
78
# File 'lib/db.rb', line 76

def migrate
  `cd #{@app_name}; rake db:migrate`
end

#save_yaml(database_hash) ⇒ Object



68
69
70
71
# File 'lib/db.rb', line 68

def save_yaml database_hash
  file = "#{@app_name}/config/database.yml"
  YAMLHelper.create_yaml file, database_hash
end