Sha256: ae2b06ce1f025eaff440ad0f229de728d84a079316bdb474881c4ea3ea86a9ed
Contents?: true
Size: 837 Bytes
Versions: 23
Compression:
Stored size: 837 Bytes
Contents
module ActiveMocker module Mock 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 end
Version data entries
23 entries across 23 versions & 1 rubygems
Version | Path |
---|---|
active_mocker-1.5.2 | lib/active_mocker/mock/object_inspect.rb |
active_mocker-1.5.1 | lib/active_mocker/mock/object_inspect.rb |
active_mocker-1.5 | lib/active_mocker/mock/object_inspect.rb |