Sha256: 73a8ffe42eb8c0df06ac9ef6f60f96aaab424bcfc6d0bd3b7edbd80d7d143b05
Contents?: true
Size: 731 Bytes
Versions: 8
Compression:
Stored size: 731 Bytes
Contents
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 keys = self.class.attributes.keys - ['id'] attributes_as_nice_string = keys.map(&:to_s).sort.map do |name| "#{name}: #{read_attribute(name).inspect}" end attributes_as_nice_string.unshift("id: #{read_attribute(:id).inspect}") "#<#{self.class}:#{object_id} #{attributes_as_nice_string.join(', ')}>" end end end
Version data entries
8 entries across 8 versions & 1 rubygems