Module: Candle::View
Instance Method Summary collapse
-
#class_config(klass) ⇒ Object
:stopdoc:.
-
#enable ⇒ Object
Enables hirb and reads a config file from the main repo’s config/hirb.yml.
-
#render(object, options = {}, return_obj = false) ⇒ Object
Renders any object via Hirb.
- #render_object(object, options = {}, return_obj = false) ⇒ Object
- #silent_object?(obj) ⇒ Boolean
- #toggle_pager ⇒ Object
Instance Method Details
#class_config(klass) ⇒ Object
:stopdoc:
25 26 27 28 29 30 31 |
# File 'lib/candle/view.rb', line 25 def class_config(klass) opts = (Hirb::View.formatter_config[klass] || {}).dup opts.delete(:ancestor) opts.merge!((opts.delete(:options) || {}).dup) OptionParser.make_mergeable!(opts) opts end |
#enable ⇒ Object
Enables hirb and reads a config file from the main repo’s config/hirb.yml.
6 7 8 9 10 11 12 |
# File 'lib/candle/view.rb', line 6 def enable unless @enabled Hirb::View.enable(:config_file=>File.join(Candle.repo.config_dir, 'hirb.yml')) Hirb::Helpers::Table.filter_any = true end @enabled = true end |
#render(object, options = {}, return_obj = false) ⇒ Object
Renders any object via Hirb. Options are passed directly to Hirb::Console.render_output.
16 17 18 19 20 21 22 |
# File 'lib/candle/view.rb', line 16 def render(object, ={}, return_obj=false) if [:inspect] puts(object.inspect) else render_object(object, , return_obj) unless silent_object?(object) end end |
#render_object(object, options = {}, return_obj = false) ⇒ Object
41 42 43 44 45 |
# File 'lib/candle/view.rb', line 41 def render_object(object, ={}, return_obj=false) [:class] ||= :auto_table render_result = Hirb::Console.render_output(object, ) return_obj ? object : render_result end |
#silent_object?(obj) ⇒ Boolean
37 38 39 |
# File 'lib/candle/view.rb', line 37 def silent_object?(obj) [nil,false,true].include?(obj) end |
#toggle_pager ⇒ Object
33 34 35 |
# File 'lib/candle/view.rb', line 33 def toggle_pager Hirb::View.toggle_pager end |