Class: Env

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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_nameObject (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

Returns:

  • (Boolean)


13
14
15
# File 'lib/did/env.rb', line 13

def allow_create?
  @allow_create
end

#database_file_exist?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/did/env.rb', line 28

def database_file_exist?
  database_path.exist?
end

#dbObject



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_recordObject



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