Module: DomainSwitcher::Cookie

Defined in:
lib/domain_switcher/cookie.rb

Class Method Summary collapse

Class Method Details

.session_storesObject

Return sessions current session_stores Warning this it not thread safe for now ! Only works with Rails 3 and Memcached session



7
8
9
10
11
12
13
14
# File 'lib/domain_switcher/cookie.rb', line 7

def self.session_stores
  return @session_stores if @session_stores
  @session_stores = nil
  ObjectSpace.each_object(ActionDispatch::Session::MemCacheStore) do |o|
    @session_stores = o
  end
  return @session_stores
end

.switch(domain) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/domain_switcher/cookie.rb', line 16

def self.switch(domain)
  if o = session_stores
    default_options = o.instance_variable_get(:@default_options)
    default_options.update(:domain => domain.cookie_domain)
    o.instance_variable_set(:@default_options, default_options)
  end
end