Class: Preseason::Config::Database

Inherits:
Object
  • Object
show all
Includes:
Preseason::Config
Defined in:
lib/preseason/config/database.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Preseason::Colorize

#ask, #readme, #yes?

Methods included from GeneratorContext

#method_missing

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Preseason::GeneratorContext

Instance Attribute Details

#databaseObject

Returns the value of attribute database.



6
7
8
# File 'lib/preseason/config/database.rb', line 6

def database
  @database
end

#passwordObject

Returns the value of attribute password.



6
7
8
# File 'lib/preseason/config/database.rb', line 6

def password
  @password
end

#usernameObject

Returns the value of attribute username.



7
8
9
# File 'lib/preseason/config/database.rb', line 7

def username
  @username
end

Instance Method Details

#adapter_nameObject



30
31
32
# File 'lib/preseason/config/database.rb', line 30

def adapter_name
  adapters[database]
end

#ask_userObject



9
10
11
12
13
14
15
16
# File 'lib/preseason/config/database.rb', line 9

def ask_user
  self.database ||= ask "What db will you be using?", :limited_to => gems.keys

  unless database == 'sqlite'
    self.username = ask "What is your #{database} database username? (leave blank for `whoami`)"
    self.password = ask "What is your #{database} database password? (leave blank for none)"
  end
end

#gem_nameObject



34
35
36
# File 'lib/preseason/config/database.rb', line 34

def gem_name
  gems[database]
end

#postgres?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/preseason/config/database.rb', line 22

def postgres?
  database == 'postgres'
end

#sqlite?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/preseason/config/database.rb', line 26

def sqlite?
  database == 'sqlite'
end