Class | Hirb::Formatter |
In: |
lib/hirb/formatter.rb
|
Parent: | Object |
A Formatter object formats an output object (using Formatter.format_output) into a string based on the views defined for its class and/or ancestry.
dynamic_config | [RW] | This config is used by Formatter.format_output to lazily load dynamic views defined with Hirb::DynamicView. This hash has the same format as Formatter.config. |
to_a_classes | [RW] | Array of classes whose objects respond to :to_a and allow the first element of the converted array to determine the output class. |
Adds the view for the given class and view hash config. See Formatter.config for valid keys for view hash.
A hash of Ruby class strings mapped to view hashes. A view hash must have at least a :method, :output_method or :class option for a view to be applied to an output. A view hash has the following keys:
Examples: {'WWW::Delicious::Element'=>{:class=>'Hirb::Helpers::ObjectTable', :ancestor=>true, :options=>{:max_width=>180}}} {'Date'=>{:class=>:auto_table, :ancestor=>true}} {'Hash'=>{:method=>:puts}}
This method looks for an output object‘s view in Formatter.config and then Formatter.dynamic_config. If a view is found, a stringified view is returned based on the object. If no view is found, nil is returned. The options this class takes are a view hash as described in Formatter.config. These options will be merged with any existing helper config hash an output class has in Formatter.config. Any block given is passed along to a helper class.