Permalink
Browse files

Add aliased field name to inspect.

Fixes #2343.
  • Loading branch information...
1 parent 36d0ba9 commit e041f194bd14cae48d69ed266178945e038a889a @i0rek i0rek committed Sep 10, 2012
Showing with 6 additions and 3 deletions.
  1. +2 −1 lib/mongoid/inspection.rb
  2. +4 −2 spec/mongoid/inspection_spec.rb
@@ -29,7 +29,8 @@ def inspect
def inspect_fields
fields.map do |name, field|
unless name == "_id"
- "#{name}: #{@attributes[name].inspect}"
+ as = field.options[:as]
+ "#{name}#{as ? "(#{as})" : nil}: #{@attributes[name].inspect}"
end
end.compact
end
@@ -17,7 +17,8 @@
let(:attributes) do
Person.fields.map do |name, field|
unless name == "_id"
- "#{name}: #{person.attributes[name].nil? ? "nil" : person.attributes[name].inspect}"
+ as = field.options[:as]
+ "#{name}#{as ? "(#{as})" : nil}: #{person.attributes[name].nil? ? "nil" : person.attributes[name].inspect}"
end
end.compact * ", "
end
@@ -36,7 +37,8 @@
let(:attributes) do
Person.fields.map do |name, field|
unless name == "_id"
- "#{name}: #{person.attributes[name].nil? ? "nil" : person.attributes[name].inspect}"
+ as = field.options[:as]
+ "#{name}#{as ? "(#{as})" : nil}: #{person.attributes[name].nil? ? "nil" : person.attributes[name].inspect}"
end
end.compact * ", "
end

0 comments on commit e041f19

Please sign in to comment.