Class: BasicDiskSettings

Inherits:
Object
  • Object
show all
Includes:
Audible, FileUtils
Defined in:
lib/rsettings/adapters/basic_disk_settings.rb

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ BasicDiskSettings

Returns a new instance of BasicDiskSettings.



6
7
8
9
10
# File 'lib/rsettings/adapters/basic_disk_settings.rb', line 6

def initialize(&block)
  @file = ".rsettings"
  _ensure
  instance_eval &block if block_given?
end

Instance Method Details

#clearObject



12
13
14
# File 'lib/rsettings/adapters/basic_disk_settings.rb', line 12

def clear
  rm file if exists?
end

#fileObject



30
# File 'lib/rsettings/adapters/basic_disk_settings.rb', line 30

def file; @file; end

#get(name) ⇒ Object



26
27
28
# File 'lib/rsettings/adapters/basic_disk_settings.rb', line 26

def get(name)
  Setting.new(settings[name.value]).tap{|result| notify_missing name if result.missing?}
end

#set(opts = {}) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/rsettings/adapters/basic_disk_settings.rb', line 16

def set(opts ={})
  opts = all.merge opts

  File.open file, "w+" do |io|
    io.puts opts.to_yaml
  end 

  notify :set, @settings
end