diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2005-11-20 08:15:51 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2005-11-20 08:15:51 +0000 |
commit | 63b792162bd999c873a4c66936ac36ac5943d53b (patch) | |
tree | 2bc30d20d228dd52488737f44b36a534e98053cc /actionpack/lib | |
parent | c7bc10b2e4a946f895071e084d0d8fde01189ae0 (diff) | |
download | rails-63b792162bd999c873a4c66936ac36ac5943d53b.tar.gz rails-63b792162bd999c873a4c66936ac36ac5943d53b.tar.bz2 rails-63b792162bd999c873a4c66936ac36ac5943d53b.zip |
Make data writer private. Marshal/unmarshal handle nil.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3108 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_controller/session/active_record_store.rb | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/actionpack/lib/action_controller/session/active_record_store.rb b/actionpack/lib/action_controller/session/active_record_store.rb index 0f1b84db68..321127495e 100644 --- a/actionpack/lib/action_controller/session/active_record_store.rb +++ b/actionpack/lib/action_controller/session/active_record_store.rb @@ -80,8 +80,8 @@ class CGI find_by_session_id(session_id) end - def marshal(data) Base64.encode64(Marshal.dump(data)) end - def unmarshal(data) Marshal.load(Base64.decode64(data)) end + def marshal(data) Base64.encode64(Marshal.dump(data)) if data end + def unmarshal(data) Marshal.load(Base64.decode64(data)) if data end def create_table! connection.execute <<-end_sql @@ -117,14 +117,14 @@ class CGI end end - attr_writer :data - # Lazy-unmarshal session state. def data - @data ||= self.class.unmarshal(read_attribute(@@data_column_name)) + @data ||= self.class.unmarshal(read_attribute(@@data_column_name)) || {} end private + attr_writer :data + def marshal_data! write_attribute(@@data_column_name, self.class.marshal(self.data)) end @@ -187,8 +187,8 @@ class CGI end end - def marshal(data) Base64.encode64(Marshal.dump(data)) end - def unmarshal(data) Marshal.load(Base64.decode64(data)) end + def marshal(data) Base64.encode64(Marshal.dump(data)) if data end + def unmarshal(data) Marshal.load(Base64.decode64(data)) if data end def create_table! @@connection.execute <<-end_sql @@ -224,7 +224,7 @@ class CGI def data unless @data if @marshaled_data - @data, @marshaled_data = self.class.unmarshal(@marshaled_data), nil + @data, @marshaled_data = self.class.unmarshal(@marshaled_data) || {}, nil else @data = {} end |