Module: Persistable

Included in:
Application
Defined in:
lib/a-commons.rb

Instance Method Summary collapse

Instance Method Details

#append_persistent_property(_persist_file, _persistent_key, _persistent_value) ⇒ Object



914
915
916
917
918
919
920
921
922
923
924
925
926
927
# File 'lib/a-commons.rb', line 914

def append_persistent_property(_persist_file, _persistent_key, _persistent_value)
  if FileTest::exist?(_persist_file)
    f = File.new(_persist_file, "w+")
    begin
      if f
        if _persistent_key
          f.syswrite(_persistent_key+'='+_persistent_value+"\n")
        end
      end
    ensure
      f.close unless f.nil?
    end
  end
end

#override_persistent(_persist_file, _persistent_hash) ⇒ Object



897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
# File 'lib/a-commons.rb', line 897

def override_persistent(_persist_file, _persistent_hash)
  if FileTest::exist?(_persist_file) && File.stat(_persist_file).writable?
    f = File.new(_persist_file, "w")
    begin
      if f
        if _persistent_hash
          _persistent_hash.each{|key,value|
            f.syswrite(key+'='+value+"\n")
          }
        end
      end
    ensure
      f.close unless f.nil?
    end
  end
end