1
0
Fork 0
mirror of https://github.com/awesome-print/awesome_print synced 2023-03-27 23:22:34 -04:00

print types as intern symbols

This commit is contained in:
Gudleik Rasch 2011-10-26 23:47:44 +02:00
parent e410508b2a
commit de82cc3a28
2 changed files with 9 additions and 9 deletions

View file

@ -22,10 +22,10 @@ module AwesomePrint
return object.inspect if !defined?(::ActiveSupport::OrderedHash) || !object.respond_to?(:fields)
data = object.fields.inject(::ActiveSupport::OrderedHash.new) do |hash, c|
hash[c[1].name] = c[1].type
hash[c[1].name] = (c[1].type || "undefined").to_s.underscore.intern
# hash[c[1].name] = (c[1].type || "undefined").to_s.underscore.intern rescue c[1].type
hash
end
"class #{object} < #{object.superclass} " << awesome_hash(data)
end
end

View file

@ -62,10 +62,10 @@ EOS
it "should print the class" do
@ap.send(:awesome, MongoUser).should == <<-EOS.strip
class MongoUser < Object {
"_id" => BSON::ObjectId < Object,
"_type" => String < Object,
"first_name" => String < Object,
"last_name" => String < Object
"_id" => :"bson/object_id",
"_type" => :string,
"first_name" => :string,
"last_name" => :string
}
EOS
end
@ -78,9 +78,9 @@ EOS
@ap.send(:awesome, Chamelion).should == <<-EOS.strip
class Chamelion < Object {
"_id" => BSON::ObjectId < Object,
"_type" => String < Object,
"last_attribute" => Mongoid::Fields::Serializable::Object < Object
"_id" => :"bson/object_id",
"_type" => :string,
"last_attribute" => :"mongoid/fields/serializable/object"
}
EOS
end