class Para::FormBuilder::Tabs::TabsManager

Attributes

builder[R]
object[R]
options[R]
template[R]

Public Class Methods

new(template, object, builder, options) click to toggle source
# File lib/para/form_builder/tabs.rb, line 15
def initialize(template, object, builder, options)
  @template = template
  @object = object
  @builder = builder
  @options = options
end

Public Instance Methods

affix?() click to toggle source
# File lib/para/form_builder/tabs.rb, line 50
def affix?
  options[:affix]
end
finalize!() click to toggle source
# File lib/para/form_builder/tabs.rb, line 31
def finalize!
  # Set all tabs as inactive if one of the tabs was set to be active
  # manually
  if tabs.any?(&:active)
    active_already_set = false

    tabs.each do |tab|
      # Get a boolean value for the current active state of the tab
      tab_active = !!tab.active

      tab.active = !active_already_set && tab_active

      # Set the "already set" flag to true once we found one active
      # tab, forcing `active = false` for all further tabs
      active_already_set ||= tab_active
    end
  end
end
tab(identifier, options = {}, &block) click to toggle source
# File lib/para/form_builder/tabs.rb, line 22
def tab(identifier, options = {}, &block)
  tabs << Tab.new(template, object, builder, identifier, options, tabs.length, &block)
  nil
end
tabs() click to toggle source
# File lib/para/form_builder/tabs.rb, line 27
def tabs
  @tabs ||= []
end