Skip to content

Commit

Permalink
Serialize Symbol as string
Browse files Browse the repository at this point in the history
  • Loading branch information
divoxx committed Oct 5, 2009
1 parent cb867f4 commit a1bd25c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/php_serialization/serializer.rb
Expand Up @@ -12,8 +12,8 @@ def run(object)
"i:#{object};"
when Float then
"d:#{object};"
when String then
"s:#{object.length}:\"#{object}\";"
when String, Symbol then
"s:#{object.to_s.length}:\"#{object}\";"
when Array then
idx = -1
items = object.map { |item| "#{run(idx += 1)}#{run(item)}" }.join
Expand Down
4 changes: 4 additions & 0 deletions spec/serialization_spec.rb
Expand Up @@ -9,6 +9,10 @@
PhpSerialization.dump("Name").should == 's:4:"Name";'
end

it "should serialize a symbol string" do
PhpSerialization.dump(:name).should == 's:4:"name";'
end

it "should serialize true" do
PhpSerialization.dump(true).should == 'b:1;'
end
Expand Down

0 comments on commit a1bd25c

Please sign in to comment.