class TinySettings::Settings

Constants

FILE_PATH

Attributes

file_path[RW]
settings[RW]

Public Class Methods

new() click to toggle source
# File lib/tiny_settings.rb, line 10
def initialize()
  @file_path ||= [FILE_PATH ,"/", "settings.yml"].join
  @settings = {}
  self
end

Public Instance Methods

load() click to toggle source
# File lib/tiny_settings.rb, line 16
def load
  begin 
    @settings = YAML.load_file(@file_path)
  rescue
    {}
  end
end
methodize!() click to toggle source
# File lib/tiny_settings.rb, line 34
def methodize!
  self.settings.methodize! 
end
save() click to toggle source
# File lib/tiny_settings.rb, line 24
def save
  File.open(@file_path, 'w') do |f|
    f.write @settings.to_yaml
  end
end
symbolize_keys() click to toggle source
# File lib/tiny_settings.rb, line 30
def symbolize_keys
  self.settings.map{|k,v| [k.to_sym, v] }.to_h
end
symbolize_keys!() click to toggle source
# File lib/tiny_settings.rb, line 38
def symbolize_keys!
  tmp_hash = symbolize_keys
  self.settings = tmp_hash
end