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



1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
# File 'lib/a-commons.rb', line 1031

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



1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
# File 'lib/a-commons.rb', line 1014

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