Class: Nesta::Config
- Inherits:
-
Object
show all
- Extended by:
- Forwardable
- Includes:
- Singleton
- Defined in:
- lib/nesta/config.rb
Defined Under Namespace
Classes: NotDefined
Constant Summary
collapse
- SETTINGS =
%w[
author
build
content
disqus_short_name
domain
google_analytics_code
read_more
subtitle
theme
title
]
Instance Attribute Summary collapse
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
45
46
47
48
49
50
51
|
# File 'lib/nesta/config.rb', line 45
def method_missing(method, *args)
if SETTINGS.include?(method.to_s)
fetch(method.to_s, nil)
else
super
end
end
|
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
30
31
32
|
# File 'lib/nesta/config.rb', line 30
def config
@config
end
|
Instance Method Details
#build ⇒ Object
57
58
59
|
# File 'lib/nesta/config.rb', line 57
def build
fetch('build', {})
end
|
#fetch(setting, *default) ⇒ Object
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/nesta/config.rb', line 32
def fetch(setting, *default)
setting = setting.to_s
self.config ||= read_config_file(setting)
env_config = config.fetch(Nesta::App.environment.to_s, {})
env_config.fetch(setting) do
config.fetch(setting) do
raise NotDefined.new(setting)
end
end
rescue NotDefined
default.empty? && raise || (return default.first)
end
|
#read_more ⇒ Object
61
62
63
|
# File 'lib/nesta/config.rb', line 61
def read_more
fetch('read_more', 'Continue reading')
end
|
#respond_to_missing?(method, include_private = false) ⇒ Boolean
53
54
55
|
# File 'lib/nesta/config.rb', line 53
def respond_to_missing?(method, include_private = false)
SETTINGS.include?(method.to_s) || super
end
|