class DiscourseTheme::Config

Attributes

filename[R]
raw_config[R]

Public Class Methods

new(filename) click to toggle source
# File lib/discourse_theme/config.rb, line 75
def initialize(filename)
  @filename = filename

  if File.exist?(@filename)
    begin
      @raw_config = YAML.load_file(@filename)
      raise unless Hash === @raw_config
    rescue
      @raw_config = {}
      $stderr.puts "ERROR: #{@filename} contains invalid config, resetting"
    end
  else
    @raw_config = {}
  end
end

Public Instance Methods

[](path) click to toggle source
# File lib/discourse_theme/config.rb, line 95
def [](path)
  PathSetting.new(self, path)
end
save() click to toggle source
# File lib/discourse_theme/config.rb, line 91
def save
  File.write(@filename, @raw_config.to_yaml)
end