From 1dd896fceed845fd58eddcf55483a4fd13434731 Mon Sep 17 00:00:00 2001 From: Mauro George Date: Thu, 19 Mar 2015 18:20:59 -0300 Subject: [PATCH] Create AwesomePrint::FormatterFactory.from --- lib/awesome_print/formatter.rb | 2 +- lib/awesome_print/formatter_factory.rb | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/awesome_print/formatter.rb b/lib/awesome_print/formatter.rb index 7dd8297..c464017 100644 --- a/lib/awesome_print/formatter.rb +++ b/lib/awesome_print/formatter.rb @@ -19,7 +19,7 @@ module AwesomePrint def format(object) @type = printable(object) @object = object - AwesomePrint::FormatterFactory.new(self, object).call + AwesomePrint::FormatterFactory.from(self, object) end # Pick the color and apply it to the given string as necessary. diff --git a/lib/awesome_print/formatter_factory.rb b/lib/awesome_print/formatter_factory.rb index 98e6346..0fc2214 100644 --- a/lib/awesome_print/formatter_factory.rb +++ b/lib/awesome_print/formatter_factory.rb @@ -3,6 +3,10 @@ require 'awesome_print/formatters' module AwesomePrint class FormatterFactory + def self.from(formatter, object) + new(formatter, object).call + end + def initialize(formatter, object) @type = AwesomePrint::TypeDiscover.new(formatter).call @class_name = @type.to_s.split('_').map(&:capitalize).join('')