Class SQLite::Database
In: lib/storage/sqlitehash.rb
Parent: Object
Database
SQLite
dot/f_49.png

Methods

[]   []=   delete   has_key?  

Public Instance methods

[Source]

# File lib/storage/sqlitehash.rb, line 17
    def [](idx)
      result = execute("select data from tmud where id = ?;", idx.to_i)
      result.first.first ? result.first.first : nil
    end

[Source]

# File lib/storage/sqlitehash.rb, line 21
    def []=(idx, data)
      result = execute("insert into tmud values (?, ?);", idx.to_i, data)
    rescue Exception
      result = execute("update tmud set data = ? where id = ?;", data, idx.to_i)
    ensure
      data
    end

[Source]

# File lib/storage/sqlitehash.rb, line 32
    def delete(idx)
      result = execute("delete from tmud where id = ?;", idx.to_i)
    rescue Exception
    end

[Source]

# File lib/storage/sqlitehash.rb, line 28
    def has_key?(idx)
      result = execute("select data from tmud where id = ?;", idx.to_i)
      result.first.first ? true : false
    end

[Validate]