diff --git a/.project b/.project
new file mode 100644
index 000000000..a6a062e87
--- /dev/null
+++ b/.project
@@ -0,0 +1,17 @@
+
+
+ mongomapper
+
+
+
+
+
+ com.aptana.ide.core.unifiedBuilder
+
+
+
+
+
+ com.aptana.ruby.core.rubynature
+
+
diff --git a/lib/mongo_mapper/plugins/inspect.rb b/lib/mongo_mapper/plugins/inspect.rb
index b6564fef3..b9009611f 100644
--- a/lib/mongo_mapper/plugins/inspect.rb
+++ b/lib/mongo_mapper/plugins/inspect.rb
@@ -5,8 +5,9 @@ module Inspect
extend ActiveSupport::Concern
module InstanceMethods
- def inspect
- attributes_as_nice_string = key_names.sort.collect do |name|
+ def inspect(include_super=false)
+ key_array = include_super ? key_names : attributes.keys
+ attributes_as_nice_string = key_array.sort.collect do |name|
"#{name}: #{self[name].inspect}"
end.join(", ")
"#<#{self.class} #{attributes_as_nice_string}>"
diff --git a/test/unit/test_inspect.rb b/test/unit/test_inspect.rb
index cc0703a93..c4d44359c 100644
--- a/test/unit/test_inspect.rb
+++ b/test/unit/test_inspect.rb
@@ -6,14 +6,19 @@ class InspectTest < Test::Unit::TestCase
@document = Doc('User') do
key :name, String
key :age, Integer
+ key :email, String
end
@doc = @document.new(:name => 'John', :age => 29)
end
- should "print out attributes in alpha sorted order" do
+ should "print out non-nil attributes in alpha sorted order" do
@doc.inspect.should =~ /_id:.*, age: 29, name: "John"/
end
+
+ should "print out all attributes when (optional) include_super argument is true" do
+ @doc.inspect(true).should =~ /_id:.*, age: 29, email: nil, name: "John"/
+ end
should "include class name" do
@doc.inspect.should =~ /^#