Method: Sip::Config#save_file

Defined in:
lib/sip/config.rb

#save_file(location) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/sip/config.rb', line 41

def save_file(location)
  # remove unecessary dbname and tablename keys
  self['databases'].each { |dbname, dbconf|
    dbconf.delete 'dbname'
    dbconf['tables'].each { |tablename, tableconf|
      tableconf.delete 'tablename'
    }
  }

  File.open(location, 'w') { |f| 
    h = Hash.new.merge self
    @temp_keys.each { |k| h.delete k }
    YAML.dump(h, f) 
  }
end