Class: TwiAuth::Store

Inherits:
Object
  • Object
show all
Defined in:
lib/twiauth/store.rb

Overview

A simple key value store using PStore, provided by ruby

Constant Summary collapse

DATA_FILE =

Filename for pstore data file

"data.pstore"

Instance Method Summary collapse

Constructor Details

#initializeStore

:nodoc:



9
10
11
# File 'lib/twiauth/store.rb', line 9

def initialize
  @store = PStore.new("#{PATH}#{DATA_FILE}")
end

Instance Method Details

#delete(key) ⇒ Object

delete a key



29
30
31
32
33
# File 'lib/twiauth/store.rb', line 29

def delete(key)
  @store.transaction do
    @store.delete(key)
  end
end

#get(key) ⇒ Object

get the value of the key



21
22
23
24
25
26
# File 'lib/twiauth/store.rb', line 21

def get(key)
  @store.transaction do
    @value = @store[key]
  end
  @value
end

#put(key, value) ⇒ Object

put a key with value



14
15
16
17
18
# File 'lib/twiauth/store.rb', line 14

def put(key, value)
  @store.transaction do
    @store[key] = value
  end
end