lib/toy/inspect.rb in toystore-0.9.0 vs lib/toy/inspect.rb in toystore-0.10.0

- old
+ new

@@ -1,12 +1,25 @@ module Toy module Inspect extend ActiveSupport::Concern + module ClassMethods + def inspect + keys = attributes.keys - ['id'] + nice_string = keys.sort.map do |name| + type = attributes[name].type + "#{name}:#{type}" + end.join(" ") + "#{name}(id:#{attributes['id'].type} #{nice_string})" + end + end + def inspect - attributes_as_nice_string = self.class.attributes.keys.map(&:to_s).sort.map do |name| + keys = self.class.attributes.keys - ['id'] + attributes_as_nice_string = keys.map(&:to_s).sort.map do |name| "#{name}: #{read_attribute(name).inspect}" - end.join(", ") - "#<#{self.class}:#{object_id} #{attributes_as_nice_string}>" + end + attributes_as_nice_string.unshift("id: #{read_attribute(:id).inspect}") + "#<#{self.class}:#{object_id} #{attributes_as_nice_string.join(', ')}>" end end -end \ No newline at end of file +end