Class: Chuusha::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/chuusha.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Config

Returns a new instance of Config.



39
40
41
42
43
44
# File 'lib/chuusha.rb', line 39

def initialize(config)
  @config     = load_config(config)
  @variables  = @config["variables"] || {}
  @cache      = @config["cache"] || {}
  default_cache_on_load_to_true
end

Instance Attribute Details

#variablesObject (readonly)

Returns the value of attribute variables.



37
38
39
# File 'lib/chuusha.rb', line 37

def variables
  @variables
end

Instance Method Details

#cache?Boolean

Returns:

  • (Boolean)


50
51
52
53
# File 'lib/chuusha.rb', line 50

def cache?
  # If we're in rails, always cache
  ENV['RAILS_ENV'] || cache_envs.include?(ENV['RACK_ENV'])
end

#cache_envsObject



46
47
48
# File 'lib/chuusha.rb', line 46

def cache_envs
  @cache["envs"] || ["production"]
end

#cache_on_load?Boolean

Returns:

  • (Boolean)


55
56
57
# File 'lib/chuusha.rb', line 55

def cache_on_load?
  @cache["on_load"] && cache?
end