Module: Halcyon::Config::Helpers::Accessors

Defined in:
lib/halcyon/config/helpers.rb

Overview

Provides several convenience accessors for configuration values, including these:

  • app: the app name

  • root: the application working directory

  • db: database configuration settings

Instance Method Summary collapse

Instance Method Details

#appObject

Accesses the app config value which is the constantized version of the application name (which can be set manually in the config file as app: NameOfApp, defaulting to a camel case version of the application directory name).



24
25
26
# File 'lib/halcyon/config/helpers.rb', line 24

def app
  self.config[:app] || ::File.dirname(self.root).camel_case
end

#app=(name) ⇒ Object

Sets the application name.



30
31
32
# File 'lib/halcyon/config/helpers.rb', line 30

def app=(name)
  self.config[:app] = name
end

#dbObject

Accesses the db config value. Intended to contain the database configuration values for whichever ORM is used.



52
53
54
# File 'lib/halcyon/config/helpers.rb', line 52

def db
  self.config[:db]
end

#db=(config) ⇒ Object

Sets the database settings.



58
59
60
# File 'lib/halcyon/config/helpers.rb', line 58

def db=(config)
  self.config[:db] = config
end

#environmentObject Also known as: env

Accesses the environment config value. Intended to contain the environment the application is running in.

Defaults to the development environment.



67
68
69
# File 'lib/halcyon/config/helpers.rb', line 67

def environment
  self.config[:environment] || :development
end

#environment=(env) ⇒ Object Also known as: env=

Sets the environment config value.



74
75
76
# File 'lib/halcyon/config/helpers.rb', line 74

def environment=(env)
  self.config[:environment] = env.to_sym
end

#hooksObject

Provides a proxy to the hooks hash.



87
88
89
# File 'lib/halcyon/config/helpers.rb', line 87

def hooks
  self.config[:hooks]
end

#pathsObject

Provides a proxy to the Halcyon::Config::Paths instance.



81
82
83
# File 'lib/halcyon/config/helpers.rb', line 81

def paths
  self.config[:paths]
end

#rootObject

Accesses the root config value which is the root of the current Halcyon application (usually Dir.pwd).

Defaults to Dir.pwd



39
40
41
# File 'lib/halcyon/config/helpers.rb', line 39

def root
  self.config[:root] || Dir.pwd rescue Dir.pwd
end

#root=(path) ⇒ Object

Sets the application root.



45
46
47
# File 'lib/halcyon/config/helpers.rb', line 45

def root=(path)
  self.config[:root] = path
end