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


1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
# File 'lib/a-commons.rb', line 1112

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


1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
# File 'lib/a-commons.rb', line 1095

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") if key && value
          }
        end
      end
    ensure
      f.close unless f.nil?
    end
  end
end