Class: Chuusha::Config
- Inherits:
-
Object
- Object
- Chuusha::Config
- Defined in:
- lib/chuusha.rb
Instance Attribute Summary collapse
-
#variables ⇒ Object
readonly
Returns the value of attribute variables.
Instance Method Summary collapse
- #cache? ⇒ Boolean
- #cache_envs ⇒ Object
- #cache_on_load? ⇒ Boolean
-
#initialize(config) ⇒ Config
constructor
A new instance of Config.
Constructor Details
#initialize(config) ⇒ Config
Returns a new instance of Config.
37 38 39 40 41 42 |
# File 'lib/chuusha.rb', line 37 def initialize(config) @config = load_config(config) @variables = @config["variables"] || {} @cache = @config["cache"] || {} default_cache_on_load_to_true end |
Instance Attribute Details
#variables ⇒ Object (readonly)
Returns the value of attribute variables.
35 36 37 |
# File 'lib/chuusha.rb', line 35 def variables @variables end |
Instance Method Details
#cache? ⇒ Boolean
48 49 50 51 |
# File 'lib/chuusha.rb', line 48 def cache? # If we're in rails, always cache ENV['RAILS_ENV'] || cache_envs.include?(ENV['RACK_ENV']) end |
#cache_envs ⇒ Object
44 45 46 |
# File 'lib/chuusha.rb', line 44 def cache_envs @cache["envs"] || ["production"] end |
#cache_on_load? ⇒ Boolean
53 54 55 |
# File 'lib/chuusha.rb', line 53 def cache_on_load? @cache["on_load"] && cache? end |