lib/helium/console.rb in helium-console-0.1.1 vs lib/helium/console.rb in helium-console-0.1.2
- old
+ new
@@ -37,10 +37,12 @@
@registry = registry
end
def format(object, **options)
options = default_options.merge(options)
+ return "(...)" if options[:ignore_objects].include?(object.object_id)
+
handler = registry.handler_for(object, **options)
if handler
handler.call
else
@@ -55,19 +57,21 @@
def define_formatter_for(klass, &handler)
registry.define(klass, &handler)
end
def simple?(object)
- SIMPLE_OBJECTS.any? {|simple_obj_class| object.is_a? simple_obj_class }
+ SIMPLE_OBJECTS.any? {|simple_obj_class| object.is_a? simple_obj_class } ||
+ registry.handler_for(object).is_simple
end
def default_options
{
overflow: :wrap,
indent: 0,
max_lines: nil,
max_width: `tput cols`.chomp.to_i,
- level: 1
+ level: 1,
+ ignore_objects: [],
}
end
def format_string(string, ellipses: "...", **options)
options = default_options.merge(options)