domain_switcher 0.1.8 → 0.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,9 +1,24 @@
1
1
  module DomainSwitcher
2
2
  module Cookie
3
3
 
4
- def self.switch(domain, env)
5
- env['rack.session.options'].update(:domain => domain.cookie_domain)
6
- env
4
+ # Return sessions current session_stores
5
+ # Warning this it not thread safe for now !
6
+ # Only works with Rails 3 and Memcached session
7
+ def self.session_stores
8
+ return @session_stores if @session_stores
9
+ @session_stores = nil
10
+ ObjectSpace.each_object(ActionDispatch::Session::MemCacheStore) do |o|
11
+ @session_stores = o
12
+ end
13
+ return @session_stores
14
+ end
15
+
16
+ def self.switch(domain)
17
+ if o = session_stores
18
+ default_options = o.instance_variable_get(:@default_options)
19
+ default_options.update(:domain => domain.cookie_domain)
20
+ o.instance_variable_set(:@default_options, default_options)
21
+ end
7
22
  end
8
23
 
9
24
  end
@@ -19,7 +19,7 @@ module DomainSwitcher
19
19
  Thread.current[:domain_switcher_website] = domain.website
20
20
 
21
21
  DomainSwitcher::Cache::switch(domain.website)
22
- env = DomainSwitcher::Cookie::switch(domain, env)
22
+ DomainSwitcher::Cookie::switch(domain)
23
23
  end
24
24
 
25
25
  @app.call(env)
metadata CHANGED
@@ -1,8 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: domain_switcher
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 9
4
5
  prerelease:
5
- version: 0.1.8
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 9
10
+ version: 0.1.9
6
11
  platform: ruby
7
12
  authors:
8
13
  - Guillaume Luccisano
@@ -10,7 +15,7 @@ autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
17
 
13
- date: 2011-05-03 00:00:00 -07:00
18
+ date: 2011-05-04 00:00:00 -07:00
14
19
  default_executable:
15
20
  dependencies:
16
21
  - !ruby/object:Gem::Dependency
@@ -21,6 +26,11 @@ dependencies:
21
26
  requirements:
22
27
  - - ">="
23
28
  - !ruby/object:Gem::Version
29
+ hash: 19
30
+ segments:
31
+ - 1
32
+ - 1
33
+ - 0
24
34
  version: 1.1.0
25
35
  type: :runtime
26
36
  version_requirements: *id001
@@ -70,12 +80,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
70
80
  requirements:
71
81
  - - ">="
72
82
  - !ruby/object:Gem::Version
83
+ hash: 3
84
+ segments:
85
+ - 0
73
86
  version: "0"
74
87
  required_rubygems_version: !ruby/object:Gem::Requirement
75
88
  none: false
76
89
  requirements:
77
90
  - - ">="
78
91
  - !ruby/object:Gem::Version
92
+ hash: 19
93
+ segments:
94
+ - 1
95
+ - 3
96
+ - 4
79
97
  version: 1.3.4
80
98
  requirements: []
81
99