Class: VfrUtils::Configuration

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

Constant Summary collapse

DEFAULTS =
{
  cache_lifetime: 900, # 900 secs = 15 minutes
  cache_directory: "#{Dir.tmpdir}/vfr_utils",
  cache_backend: :files,
  redis_url: nil,
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(defaults = DEFAULTS) ⇒ Configuration

Returns a new instance of Configuration.


16
17
18
19
20
21
22
# File 'lib/vfr_utils/configuration.rb', line 16

def initialize(defaults=DEFAULTS)
  @cache_lifetime = defaults[:cache_lifetime] || DEFAULTS[:cache_lifetime]
  @cache_directory = defaults[:cache_directory] || DEFAULTS[:cache_directory]
  @cache_backend = defaults[:cache_backend] || DEFAULTS[:cache_backend]
  @redis_url = defaults[:redis_url] || DEFAULTS[:redis_url]
  apply
end

Instance Attribute Details

#cache_backendObject

Returns the value of attribute cache_backend


13
14
15
# File 'lib/vfr_utils/configuration.rb', line 13

def cache_backend
  @cache_backend
end

#cache_directoryObject

Returns the value of attribute cache_directory


12
13
14
# File 'lib/vfr_utils/configuration.rb', line 12

def cache_directory
  @cache_directory
end

#cache_lifetimeObject

Returns the value of attribute cache_lifetime


11
12
13
# File 'lib/vfr_utils/configuration.rb', line 11

def cache_lifetime
  @cache_lifetime
end

#redis_urlObject

Returns the value of attribute redis_url


14
15
16
# File 'lib/vfr_utils/configuration.rb', line 14

def redis_url
  @redis_url
end

Instance Method Details

#applyObject


24
25
26
# File 'lib/vfr_utils/configuration.rb', line 24

def apply
  FileUtils.mkdir_p @cache_directory if @cache_backend == :files
end