mongoid_session_store 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.0
1
+ 1.1.0
@@ -1,18 +1,18 @@
1
1
  module ActionDispatch
2
2
  module Session
3
3
  class MongoidStore < AbstractStore
4
-
4
+
5
5
  class Session
6
6
  include Mongoid::Document
7
7
  include Mongoid::Timestamps
8
-
8
+
9
9
  store_in :sessions
10
10
 
11
+ identity :type => String
12
+
11
13
  field :data, :type => String, :default => [Marshal.dump({})].pack("m*")
12
- field :session_id, :type => String, :allow_nil => false
13
-
14
+
14
15
  index :updated_at
15
- index :session_id
16
16
  end
17
17
 
18
18
  # The class used for session storage.
@@ -22,8 +22,8 @@ module ActionDispatch
22
22
  SESSION_RECORD_KEY = 'rack.session.record'.freeze
23
23
 
24
24
  private
25
-
26
- def get_session(env, sid)
25
+
26
+ def get_session(env, sid)
27
27
  session = find_session(sid)
28
28
  env[SESSION_RECORD_KEY] = session
29
29
  [sid, unpack(session.data)]
@@ -39,16 +39,16 @@ module ActionDispatch
39
39
  record.save ? sid : false
40
40
  end
41
41
 
42
- def find_session(id)
43
- @@session_class.where(:session_id => id).first || @@session_class.new(:session_id => id)
42
+ def find_session(id)
43
+ @@session_class.find_or_create_by(:id => id)
44
44
  end
45
-
45
+
46
46
  def destroy(env)
47
47
  if sid = current_session_id(env)
48
48
  find_session(sid).destroy
49
49
  end
50
50
  end
51
-
51
+
52
52
  def get_session_model(env, sid)
53
53
  if env[ENV_SESSION_OPTIONS_KEY][:id].nil?
54
54
  env[SESSION_RECORD_KEY] = find_session(sid)
@@ -65,7 +65,7 @@ module ActionDispatch
65
65
  return nil unless packed
66
66
  Marshal.load(packed.unpack("m*").first)
67
67
  end
68
-
68
+
69
69
  end
70
70
  end
71
71
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{mongoid_session_store}
8
- s.version = "1.0.0"
8
+ s.version = "1.1.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Ryan Fitzgerald"]
12
- s.date = %q{2010-08-30}
12
+ s.date = %q{2010-09-30}
13
13
  s.description = %q{store rails 3 sessions in mongoDB}
14
14
  s.email = %q{ryan@gymlogr.com}
15
15
  s.extra_rdoc_files = [
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 1
7
+ - 1
7
8
  - 0
8
- - 0
9
- version: 1.0.0
9
+ version: 1.1.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Ryan Fitzgerald
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-08-30 00:00:00 -04:00
17
+ date: 2010-09-30 00:00:00 -04:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency