class Tabulous::RenderingCoordinator

Public Class Methods

new(tabset, view) click to toggle source
# File lib/tabulous/rendering_coordinator.rb, line 20
def initialize(tabset, view)
  @view = view
  @tabset = tabset
  begin
    @renderer = "Tabulous::#{Config.renderer.to_s.camelize}Renderer".constantize.new(tabset, view)
  rescue NameError
    @renderer = "#{Config.renderer.to_s.camelize}Renderer".constantize.new(tabset, view)
  end
end

Public Instance Methods

render_subtabs() click to toggle source
# File lib/tabulous/rendering_coordinator.rb, line 38
def render_subtabs
  return if check_for_active_tab == :do_not_render
  return '' if @tabset.visible_subtabs(@view).empty? && !Config.render_subtabs_when_empty
  html = ''
  html << @renderer.subtabs_html
  @view.raw(html)
end
render_tabs() click to toggle source
# File lib/tabulous/rendering_coordinator.rb, line 30
def render_tabs
  return if check_for_active_tab == :do_not_render
  html = ''
  html << CssScaffolding.embeddable_styles if Config.use_css_scaffolding
  html << @renderer.tabs_html
  @view.raw(html)
end

Private Instance Methods

check_for_active_tab() click to toggle source
# File lib/tabulous/rendering_coordinator.rb, line 48
def check_for_active_tab
  if !@tabset.active_primary_tab(@view)
    if Config.when_action_has_no_tab == :raise_error
      msg = "No tab is defined for the action '#{@view.action_name}' in the controller '#{@view.controller_path}'."
      msg << " One of your tabs should have a valid active_when declaration that hooks it up to this controller action."
      raise NoTabFoundError, msg
    else
      return Config.when_action_has_no_tab
    end
  end
end