Class: Tzispa::Config::AppConfig
- Inherits:
-
Object
- Object
- Tzispa::Config::AppConfig
- Includes:
- Helpers::Security
- Defined in:
- lib/tzispa/config/app_config.rb
Constant Summary collapse
- CONFIG_FILENAME =
:appconfig
Instance Attribute Summary collapse
-
#cfname ⇒ Object
readonly
Returns the value of attribute cfname.
-
#domain ⇒ Object
readonly
Returns the value of attribute domain.
Instance Method Summary collapse
- #create_default(default_layout, locale) ⇒ Object
- #filename ⇒ Object
-
#initialize(domain) ⇒ AppConfig
constructor
A new instance of AppConfig.
- #load! ⇒ Object
Constructor Details
#initialize(domain) ⇒ AppConfig
Returns a new instance of AppConfig.
15 16 17 18 |
# File 'lib/tzispa/config/app_config.rb', line 15 def initialize(domain) @domain = domain @cftime = nil end |
Instance Attribute Details
#cfname ⇒ Object (readonly)
Returns the value of attribute cfname.
13 14 15 |
# File 'lib/tzispa/config/app_config.rb', line 13 def cfname @cfname end |
#domain ⇒ Object (readonly)
Returns the value of attribute domain.
13 14 15 |
# File 'lib/tzispa/config/app_config.rb', line 13 def domain @domain end |
Instance Method Details
#create_default(default_layout, locale) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/tzispa/config/app_config.rb', line 34 def create_default(default_layout, locale) hcfg = {}.tap do |cfg| cfg['default_layout'] = default_layout cfg['default_format'] = 'htm' cfg['default_encoding'] = 'utf-8' cfg['absolute_redirects'] = true cfg['salt'] = secret(24) cfg['secret'] = secret(36) cfg['locales'] = {}.tap do |loc| loc['preload'] = true loc['default'] = locale end cfg['logging'] = {}.tap do |log| log['enabled'] = true log['shift_age'] = 'daily' end cfg['sessions'] = {}.tap { |ses| ses['enabled'] = false } end Tzispa::Config::Yaml.save(hcfg, filename) load! end |
#filename ⇒ Object
20 21 22 |
# File 'lib/tzispa/config/app_config.rb', line 20 def filename @filename ||= "config/#{domain.name}.yml" end |