Class: Env
- Inherits:
-
Object
- Object
- Env
- Defined in:
- lib/did/env.rb
Instance Attribute Summary collapse
-
#profile_name ⇒ Object
readonly
Returns the value of attribute profile_name.
Instance Method Summary collapse
- #allow_create? ⇒ Boolean
- #database_file_exist? ⇒ Boolean
- #db ⇒ Object
-
#initialize(profile_name, allow_create = true) ⇒ Env
constructor
A new instance of Env.
- #setup_active_record ⇒ Object
- #setup_development(environment_name) ⇒ Object
Constructor Details
#initialize(profile_name, allow_create = true) ⇒ Env
Returns a new instance of Env.
8 9 10 11 |
# File 'lib/did/env.rb', line 8 def initialize(profile_name, allow_create = true) @profile_name = profile_name @allow_create = allow_create end |
Instance Attribute Details
#profile_name ⇒ Object (readonly)
Returns the value of attribute profile_name.
6 7 8 |
# File 'lib/did/env.rb', line 6 def profile_name @profile_name end |
Instance Method Details
#allow_create? ⇒ Boolean
13 14 15 |
# File 'lib/did/env.rb', line 13 def allow_create? @allow_create end |
#database_file_exist? ⇒ Boolean
28 29 30 |
# File 'lib/did/env.rb', line 28 def database_file_exist? database_path.exist? end |
#db ⇒ Object
32 33 34 35 |
# File 'lib/did/env.rb', line 32 def db return nil if !allow_create? && !database_file_exist? @@db ||= SQLite3::Database.new(database_path.to_s) end |
#setup_active_record ⇒ Object
17 18 19 20 21 |
# File 'lib/did/env.rb', line 17 def setup_active_record initialize_home config = {"adapter" => 'sqlite3', "database" => database_path.to_s} ActiveRecord::Base.establish_connection(config) end |
#setup_development(environment_name) ⇒ Object
23 24 25 26 |
# File 'lib/did/env.rb', line 23 def setup_development(environment_name) config = development_database_config(environment_name) ActiveRecord::Base.establish_connection(config) end |