couchrest_session_store 0.0.4 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/couchrest_session_store.rb +13 -11
- metadata +2 -2
@@ -45,22 +45,17 @@ class CouchRestSessionStore < ActionDispatch::Session::AbstractStore
|
|
45
45
|
if sid
|
46
46
|
doc = database.get(sid)
|
47
47
|
session = self.class.unmarshal(doc["data"])
|
48
|
+
[sid, session]
|
48
49
|
else
|
49
|
-
|
50
|
-
session = {}
|
51
|
-
doc = CouchRest::Document.new "_id" => sid,
|
52
|
-
"data" => self.class.marshal(session)
|
53
|
-
database.save_doc(doc)
|
50
|
+
[generate_sid, {}]
|
54
51
|
end
|
55
|
-
return [sid, session]
|
56
52
|
rescue RestClient::ResourceNotFound
|
57
|
-
# session does not exist anymore
|
58
|
-
|
53
|
+
# session data does not exist anymore
|
54
|
+
return [sid, {}]
|
59
55
|
end
|
60
56
|
|
61
57
|
def set_session(env, sid, session, options)
|
62
|
-
doc =
|
63
|
-
doc["data"] = self.class.marshal(session)
|
58
|
+
doc = build_or_update_doc(sid, self.class.marshal(session))
|
64
59
|
database.save_doc(doc)
|
65
60
|
return sid
|
66
61
|
end
|
@@ -68,12 +63,19 @@ class CouchRestSessionStore < ActionDispatch::Session::AbstractStore
|
|
68
63
|
def destroy_session(env, sid, options)
|
69
64
|
doc = database.get(sid)
|
70
65
|
database.delete_doc(doc)
|
71
|
-
|
66
|
+
options[:drop] ? nil : generate_sid
|
72
67
|
rescue RestClient::ResourceNotFound
|
73
68
|
# already destroyed - we're done.
|
74
69
|
end
|
75
70
|
|
76
71
|
|
72
|
+
def build_or_update_doc(sid, data)
|
73
|
+
doc = database.get(sid)
|
74
|
+
doc["data"] = data
|
75
|
+
return doc
|
76
|
+
rescue RestClient::ResourceNotFound
|
77
|
+
return CouchRest::Document.new "_id" => sid, "data" => data
|
78
|
+
end
|
77
79
|
|
78
80
|
end
|
79
81
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: couchrest_session_store
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-02-
|
12
|
+
date: 2013-02-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: couchrest
|