Class: Semistatic::Configuration
- Inherits:
-
Object
- Object
- Semistatic::Configuration
- Defined in:
- lib/semistatic/configuration.rb
Defined Under Namespace
Classes: Error
Instance Method Summary collapse
-
#config_files ⇒ Object
get the config files.
-
#config_files=(files) ⇒ Object
set the config files.
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
-
#load ⇒ Object
load config from files.
-
#page(key) ⇒ Object
Hash.
-
#pages ⇒ Object
Hash.
-
#templates_path ⇒ Object
get the template path.
-
#templates_path=(path) ⇒ Object
set the template path.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
7 8 9 10 11 |
# File 'lib/semistatic/configuration.rb', line 7 def initialize @templates_path = Rails.root. + 'app/views/layout' @config_files = [(Rails.root. + 'config/semistatic.yml')] @config = HashWithIndifferentAccess.new({pages: {}}) end |
Instance Method Details
#config_files ⇒ Object
get the config files
33 34 35 |
# File 'lib/semistatic/configuration.rb', line 33 def config_files @config_files end |
#config_files=(files) ⇒ Object
set the config files
27 28 29 |
# File 'lib/semistatic/configuration.rb', line 27 def config_files=(files) @config_files = files end |
#load ⇒ Object
load config from files
38 39 40 41 42 43 |
# File 'lib/semistatic/configuration.rb', line 38 def load config_files.each do |file| config = YAML::load(File.open(file)) @config.merge! config end end |
#page(key) ⇒ Object
Returns hash.
52 53 54 55 56 |
# File 'lib/semistatic/configuration.rb', line 52 def page(key) page = pages[key] raise Error.new("There is no page named '#{key}'") unless page page end |
#pages ⇒ Object
Returns Hash.
46 47 48 |
# File 'lib/semistatic/configuration.rb', line 46 def pages @config[:pages] end |
#templates_path ⇒ Object
get the template path
21 22 23 |
# File 'lib/semistatic/configuration.rb', line 21 def templates_path @templates_path end |
#templates_path=(path) ⇒ Object
set the template path
15 16 17 |
# File 'lib/semistatic/configuration.rb', line 15 def templates_path=(path) @templates_path = path end |