Class: Cran::PStoreAdapter

Inherits:
Object
  • Object
show all
Includes:
Adapter
Defined in:
lib/cran/p_store.rb

Class Method Summary collapse

Methods included from Adapter

included

Class Method Details

.connectionObject



9
10
11
# File 'lib/cran/p_store.rb', line 9

def connection
  @connection ||= PStore.new(Config.get(:db, :filename))
end

.delete(key) ⇒ Object



31
32
33
# File 'lib/cran/p_store.rb', line 31

def delete(key)
  transaction{connection.delete(key)}
end

.delete_allObject



35
36
37
38
39
40
41
# File 'lib/cran/p_store.rb', line 35

def delete_all
  transaction do
    connection.roots.each do |key|
      connection.delete(key)
    end
  end
end

.listObject



21
22
23
# File 'lib/cran/p_store.rb', line 21

def list
  transaction{connection.roots}
end

.pull(key) ⇒ Object



13
14
15
# File 'lib/cran/p_store.rb', line 13

def pull(key)
  transaction{super}
end

.push(key, value) ⇒ Object



17
18
19
# File 'lib/cran/p_store.rb', line 17

def push(key, value)
  transaction{super}
end

.transactionObject



25
26
27
28
29
# File 'lib/cran/p_store.rb', line 25

def transaction
  connection.transaction do
    yield
  end
end