Class: WebResourceBundler::Settings
- Inherits:
-
Object
- Object
- WebResourceBundler::Settings
- Defined in:
- lib/web_resource_bundler/settings.rb
Constant Summary collapse
- DEFAULT_RESOURCE_DIR =
'public'
- DEFAULT_SETTINGS_PATH =
'config/web_resource_bundler.yml'
- DEFAULT_CACHE_DIR =
'cache'
- OBLIGATORY_SETTINGS =
[:resource_dir, :cache_dir]
Class Attribute Summary collapse
-
.settings ⇒ Object
Returns the value of attribute settings.
Class Method Summary collapse
-
.correct?(settings = @settings) ⇒ Boolean
ensures that settings has obligatory keys present.
-
.create_settings(rails_root, rails_env) ⇒ Object
creates settings from config file and merging them with defaults.
-
.filter_settings(filter_name) ⇒ Object
returns setting for particular filter, merged with common settings.
- .filter_used?(name) ⇒ Boolean
-
.set(settings) ⇒ Object
sets new settings by merging with existing.
-
.set_request_specific_data!(settings, domain, protocol) ⇒ Object
setting request specific settings like domain and protocol.
Class Attribute Details
.settings ⇒ Object
Returns the value of attribute settings.
11 12 13 |
# File 'lib/web_resource_bundler/settings.rb', line 11 def settings @settings end |
Class Method Details
.correct?(settings = @settings) ⇒ Boolean
ensures that settings has obligatory keys present
22 23 24 25 |
# File 'lib/web_resource_bundler/settings.rb', line 22 def correct?(settings = @settings) OBLIGATORY_SETTINGS.each { |key| return false unless settings.has_key?(key) } true end |
.create_settings(rails_root, rails_env) ⇒ Object
creates settings from config file and merging them with defaults
15 16 17 18 19 |
# File 'lib/web_resource_bundler/settings.rb', line 15 def create_settings(rails_root, rails_env) config = self.read_from_file(rails_root, rails_env) @settings = self.defaults(rails_root).merge(config) @settings end |
.filter_settings(filter_name) ⇒ Object
returns setting for particular filter, merged with common settings
28 29 30 |
# File 'lib/web_resource_bundler/settings.rb', line 28 def filter_settings(filter_name) self.commons(@settings).merge(@settings[filter_name]) end |
.filter_used?(name) ⇒ Boolean
44 45 46 |
# File 'lib/web_resource_bundler/settings.rb', line 44 def filter_used?(name) @settings[name] && @settings[name][:use] end |
.set(settings) ⇒ Object
sets new settings by merging with existing
40 41 42 |
# File 'lib/web_resource_bundler/settings.rb', line 40 def set(settings) @settings.merge!(settings) end |
.set_request_specific_data!(settings, domain, protocol) ⇒ Object
setting request specific settings like domain and protocol
33 34 35 36 37 |
# File 'lib/web_resource_bundler/settings.rb', line 33 def set_request_specific_data!(settings, domain, protocol) settings[:domain] = domain settings[:protocol] = protocol settings end |