summaryrefslogtreecommitdiff
path: root/vendor/gems/couchrest_session_store/test/couch_tester.rb
blob: b6230445c644a2bbcebfca3c78b8c010245533d2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#
# Access the couch directly so we can test its state without relying
# on the SessionStore
#

class CouchTester < CouchRest::Document
  include CouchRest::Model::Configuration
  include CouchRest::Model::Connection
  include CouchRest::Model::Rotation

  rotate_database 'sessions',
    :every => 1.month, :expiration_field => :expires

  def initialize(options = {})
  end

  def get(sid)
    database.get(sid)
  end

  def update(sid, diff)
    doc = database.get(sid)
    doc.merge! diff
    database.save_doc(doc)
  end

end