class Expirer::Config

Constants

DEFAULTS
OPTIONS

Public Class Methods

new() click to toggle source
# File lib/expirer/config.rb, line 15
def initialize
  reset!
end

Public Instance Methods

expire_date() click to toggle source
# File lib/expirer/config.rb, line 31
def expire_date
  @parsed_expire_date ||= Chronic.parse(@expire_date).to_datetime
end
load_from_file!(file) click to toggle source
# File lib/expirer/config.rb, line 19
def load_from_file!(file)
  set_options(config_from_file(file)) if file && File.exists?(file)
end
load_from_options!(options) click to toggle source
# File lib/expirer/config.rb, line 27
def load_from_options!(options)
  set_options(options.underscore_keys.symbolize_keys)
end
private_only?() click to toggle source
# File lib/expirer/config.rb, line 35
def private_only?
  private_only
end
reset!() click to toggle source
# File lib/expirer/config.rb, line 23
def reset!
  set_options(DEFAULTS)
end

Private Instance Methods

config_from_file(file) click to toggle source
# File lib/expirer/config.rb, line 41
def config_from_file(file)
  @config_from_file ||= YAML.load(File.read(file)).symbolize_keys
end
set_option(key, value) click to toggle source
# File lib/expirer/config.rb, line 45
def set_option(key, value)
  self.send("#{key}=", value)
end
set_options(storage) click to toggle source
# File lib/expirer/config.rb, line 55
def set_options(storage)
  with_options do |key|
    set_option(key, storage[key]) if storage.include?(key)
  end
end
with_options() { |key| ... } click to toggle source
# File lib/expirer/config.rb, line 49
def with_options
  OPTIONS.each do |key|
    yield(key)
  end
end