add hash with object

This commit is contained in:
Torsten Ruger 2014-08-15 17:18:15 +03:00
parent 16261f96b0
commit 0a7814a07b
2 changed files with 11 additions and 1 deletions

View File

@ -31,6 +31,12 @@ module Sof
add(a , level + 1)
end
end
if( object.is_a? Hash )
object.each do |a,b|
add(a , level + 1)
add(b , level + 1)
end
end
end
end
end

View File

@ -43,7 +43,11 @@ class BasicSof < MiniTest::Test
end
def test_simple_hash
out = Sof::Writer.write({ one: 1 , tru: true })
puts out
assert_equal "-:one 1\n-:tru true\n" , out
end
def test_hash_object
out = Sof::Writer.write({ one: 1 , two: ObjectWithAttributes.new })
puts out
assert_equal "-:one 1\n-:two #{OBJECT_STRING}\n\n" , out
end
end