has_global_session 0.8.9 → 0.8.10
Sign up to get free protection for your applications and to get access to all the features.
data/has_global_session.gemspec
CHANGED
@@ -7,8 +7,8 @@ spec = Gem::Specification.new do |s|
|
|
7
7
|
s.required_ruby_version = Gem::Requirement.new(">= 1.8.7")
|
8
8
|
|
9
9
|
s.name = 'has_global_session'
|
10
|
-
s.version = '0.8.
|
11
|
-
s.date = '2010-
|
10
|
+
s.version = '0.8.10'
|
11
|
+
s.date = '2010-07-01'
|
12
12
|
|
13
13
|
s.authors = ['Tony Spataro']
|
14
14
|
s.email = 'code@tracker.xeger.net'
|
@@ -1,51 +1,53 @@
|
|
1
1
|
module HasGlobalSession
|
2
2
|
class IntegratedSession
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
attr_reader :local, :global
|
4
|
+
|
5
|
+
def initialize(local, global)
|
6
|
+
@local = local
|
7
|
+
@global = global
|
6
8
|
end
|
7
9
|
|
8
10
|
def [](key)
|
9
11
|
key = key.to_s
|
10
|
-
if @
|
11
|
-
@
|
12
|
+
if @global.supports_key?(key)
|
13
|
+
@global[key]
|
12
14
|
else
|
13
|
-
@
|
15
|
+
@local[key]
|
14
16
|
end
|
15
17
|
end
|
16
18
|
|
17
19
|
def []=(key, value)
|
18
20
|
key = key.to_s
|
19
|
-
if @
|
20
|
-
@
|
21
|
+
if @global.supports_key?(key)
|
22
|
+
@global[key] = value
|
21
23
|
else
|
22
|
-
@
|
24
|
+
@local[key] = value
|
23
25
|
end
|
24
26
|
end
|
25
27
|
|
26
28
|
def has_key?(key)
|
27
29
|
key = key.to_s
|
28
|
-
@
|
30
|
+
@global.has_key(key) || @local.has_key?(key)
|
29
31
|
end
|
30
32
|
|
31
33
|
def keys
|
32
|
-
@
|
34
|
+
@global.keys + @local.keys
|
33
35
|
end
|
34
36
|
|
35
37
|
def values
|
36
|
-
@
|
38
|
+
@global.values + @local.values
|
37
39
|
end
|
38
40
|
|
39
41
|
def each_pair(&block)
|
40
|
-
@
|
41
|
-
@
|
42
|
+
@global.each_pair(&block)
|
43
|
+
@local.each_pair(&block)
|
42
44
|
end
|
43
45
|
|
44
46
|
def method_missing(meth, *args)
|
45
|
-
if @
|
46
|
-
return @
|
47
|
-
elsif @
|
48
|
-
return @
|
47
|
+
if @global.respond_to?(meth)
|
48
|
+
return @global.send(meth, *args)
|
49
|
+
elsif @local.respond_to?(meth)
|
50
|
+
return @local.send(meth, *args)
|
49
51
|
else
|
50
52
|
super
|
51
53
|
end
|
@@ -12,7 +12,10 @@ module HasGlobalSession
|
|
12
12
|
|
13
13
|
def session_with_global_session
|
14
14
|
if global_session
|
15
|
-
@integrated_session
|
15
|
+
unless @integrated_session && (@integrated_session.global == @global_session)
|
16
|
+
@integrated_session =
|
17
|
+
IntegratedSession.new(session_without_global_session, global_session)
|
18
|
+
end
|
16
19
|
return @integrated_session
|
17
20
|
else
|
18
21
|
return session_without_global_session
|
@@ -38,9 +41,9 @@ module HasGlobalSession
|
|
38
41
|
rescue Exception => e
|
39
42
|
#silently recover from any error by initializing a new global session
|
40
43
|
@global_session = GlobalSession.new(directory)
|
41
|
-
global_session_update_cookie
|
42
44
|
#give the Rails app a chance to handle the exception
|
43
|
-
|
45
|
+
#unless it's an ExpiredSession, which we handle transparently
|
46
|
+
raise e unless e.is_a?(ExpiredSession)
|
44
47
|
end
|
45
48
|
end
|
46
49
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: has_global_session
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 43
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 8
|
9
|
-
-
|
10
|
-
version: 0.8.
|
9
|
+
- 10
|
10
|
+
version: 0.8.10
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Tony Spataro
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-07-01 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|