> Frederick Cheung wrote:
>>
>> Struct.new('FakeSession', :session_id)
>> fake_cgi_session = Struct::FakeSession.new('some session id')
>>
>> session = WhateverSessionStoreClass.new(fake_cgi_session)
>> session.restore
>>
Okay, pre-Rails-2.2, if you want to fake a session and you want to have
it work to create a new session with that ID even if one doesn't
currently exist, and you sometimes use an ActiveRecord session store
(phew), then instead of simply using a Struct to create a duck-typed
fake session, you need something that will implement new_session too,
still using the same session_id.
class FakeSession
attr_accessor :session_id
def initialize(a_session_id)
self.session_id = a_session_id
end
def new_session
return self.session_id
end
end
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---