method
inspect
v6.0.0 -
Show latest stable
- Class:
ActiveRecord::Core
inspect()public
Returns the contents of the record as a nicely formatted string.
# File activerecord/lib/active_record/core.rb, line 503
def inspect
# We check defined?(@attributes) not to issue warnings if the object is
# allocated but not initialized.
inspection = if defined?(@attributes) && @attributes
self.class.attribute_names.collect do |name|
if has_attribute?(name)
attr = _read_attribute(name)
value = if attr.nil?
attr.inspect
else
attr = format_for_inspect(attr)
inspection_filter.filter_param(name, attr)
end
"#{name}: #{value}"
end
end.compact.join(", ")
else
"not initialized"
end
"#<#{self.class} #{inspection}>"
end Related methods
- Instance methods
- <=>
- ==
- blank?
- clone
- connection_handler
- dup
- encode_with
- eql?
- freeze
- frozen?
- hash
- init_with
- init_with_attributes
- initialize_dup
- inspect
- present?
- pretty_print
- readonly!
- readonly?
- slice
- Class methods
- configurations
- configurations=
- connection_handler
- connection_handler=
- new
- Private methods
-
custom_inspect_method_defined? -
init_internals -
initialize_internals_callback -
inspection_filter -
to_ary