Sha256: c8db1d4abe954c452d658b03232477b11fd9f6f1f82a478506e6f35f3273d985
Contents?: true
Size: 975 Bytes
Versions: 2
Compression:
Stored size: 975 Bytes
Contents
module Picky module Backends class SQLite class Array < Basic def create_table db.execute 'create table key_value (key varchar(255), value text);' end def []= key, array unless array.empty? db.execute 'INSERT OR REPLACE INTO key_value (key,value) VALUES (?,?)', key.to_s, Yajl::Encoder.encode(array) end DirectlyManipulable.make self, array, key array end def [] key res = db.execute "SELECT value FROM key_value WHERE key = ? LIMIT 1", key.to_s return nil unless res array = res.empty? ? [] : Yajl::Parser.parse(res.first.first) DirectlyManipulable.make self, array, key array end def delete key db.execute "DELETE FROM key_value WHERE key = (?)", key.to_s end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
picky-3.6.10 | lib/picky/backends/sqlite/array.rb |
picky-3.6.9 | lib/picky/backends/sqlite/array.rb |