Class: CouchRest::Session::Store

Inherits:
ActionDispatch::Session::AbstractStore
  • Object
show all
Defined in:
lib/couchrest/session/store.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app, options = {}) ⇒ Store

Returns a new instance of Store.



15
16
17
18
# File 'lib/couchrest/session/store.rb', line 15

def initialize(app, options = {})
  super
  self.class.set_options(options)
end

Class Method Details

.configure(*args, &block) ⇒ Object

delegate configure to document



4
5
6
# File 'lib/couchrest/session/store.rb', line 4

def self.configure(*args, &block)
  CouchRest::Session::Document.configure *args, &block
end

.set_options(options) ⇒ Object



8
9
10
11
12
13
# File 'lib/couchrest/session/store.rb', line 8

def self.set_options(options)
  @options = options
  if @options[:database]
    CouchRest::Session::Document.use_database @options[:database]
  end
end

Instance Method Details

#cleanup(rows) ⇒ Object



20
21
22
23
24
25
# File 'lib/couchrest/session/store.rb', line 20

def cleanup(rows)
  rows.each do |row|
    doc = CouchRest::Session::Document.fetch(row['id'])
    doc.delete
  end
end

#expiredObject



27
28
29
30
# File 'lib/couchrest/session/store.rb', line 27

def expired
  CouchRest::Session::Document.find_by_expires startkey: 1,
    endkey: Time.now.utc.iso8601
end

#never_expiringObject



32
33
34
# File 'lib/couchrest/session/store.rb', line 32

def never_expiring
  CouchRest::Session::Document.find_by_expires endkey: 1
end