diff options
author | Sean Griffin <sean@thoughtbot.com> | 2015-01-23 16:25:15 -0700 |
---|---|---|
committer | Sean Griffin <sean@thoughtbot.com> | 2015-01-23 16:25:15 -0700 |
commit | 847395a04df52a389823ff4367c4b002cdbb5c6a (patch) | |
tree | 4aeae6e22bf53888e2766ffb090182c541270dcb /activerecord/lib/active_record | |
parent | 7a69e27cdef97159464d76cf93a52f2ee16af010 (diff) | |
parent | f5c2bf10979a3e0d5f33665660c06423b967e4ec (diff) | |
download | rails-847395a04df52a389823ff4367c4b002cdbb5c6a.tar.gz rails-847395a04df52a389823ff4367c4b002cdbb5c6a.tar.bz2 rails-847395a04df52a389823ff4367c4b002cdbb5c6a.zip |
Merge pull request #18474 from notEthan/pretty_print_inspect
pretty_print will use #inspect if a subclass redefines it
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/core.rb | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/core.rb b/activerecord/lib/active_record/core.rb index a7aff9f724..4705f129f2 100644 --- a/activerecord/lib/active_record/core.rb +++ b/activerecord/lib/active_record/core.rb @@ -456,6 +456,7 @@ module ActiveRecord # Takes a PP and prettily prints this record to it, allowing you to get a nice result from `pp record` # when pp is required. def pretty_print(pp) + return super if custom_inspect_method_defined? pp.object_address_group(self) do if defined?(@attributes) && @attributes column_names = self.class.column_names.select { |name| has_attribute?(name) || new_record? } @@ -560,5 +561,9 @@ module ActiveRecord @attributes = @attributes.dup end end + + def custom_inspect_method_defined? + self.class.instance_method(:inspect).owner != ActiveRecord::Base.instance_method(:inspect).owner + end end end |