Sha256: c1beac805dcbbbc30e20fbf5dec9127e44f8a7b1996e53092328e0de75d4b6a6
Contents?: true
Size: 884 Bytes
Versions: 7
Compression:
Stored size: 884 Bytes
Contents
module ActiveMocker class ObjectInspect def initialize(class_name, attributes) @class_name = class_name @attributes = attributes @string = create_inspections end def to_s @string end def to_str @string end private def create_inspections inspection = @attributes.map do |name, value| "#{name}: #{object_for_inspect(value)}" end "#<#{@class_name} #{inspection.compact.join(", ")}>" end def object_for_inspect(value) if value.is_a?(String) && value.length > 50 "#{value[0, 50]}...".inspect elsif value.is_a?(Date) || value.is_a?(Time) %("#{value.to_s(:db)}") elsif value.is_a?(Array) && value.size > 10 inspected = value.first(10).inspect %(#{inspected[0...-1]}, ...]) else value.inspect end end end end
Version data entries
7 entries across 7 versions & 1 rubygems