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.



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

#variablesObject (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

Returns:

  • (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_envsObject



44
45
46
# File 'lib/chuusha.rb', line 44

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

#cache_on_load?Boolean

Returns:

  • (Boolean)


53
54
55
# File 'lib/chuusha.rb', line 53

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