domain_switcher 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -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,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: domain_switcher
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 6
10
- version: 0.1.6
9
+ - 7
10
+ version: 0.1.7
11
11
  platform: ruby
12
12
  authors:
13
13
  - Guillaume Luccisano
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-03-29 00:00:00 -07:00
18
+ date: 2011-04-21 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency