Class: Para::FormBuilder::Tabs::TabsManager
- Inherits:
-
Object
- Object
- Para::FormBuilder::Tabs::TabsManager
- Defined in:
- lib/para/form_builder/tabs.rb
Instance Attribute Summary collapse
-
#builder ⇒ Object
readonly
Returns the value of attribute builder.
-
#object ⇒ Object
readonly
Returns the value of attribute object.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#template ⇒ Object
readonly
Returns the value of attribute template.
Instance Method Summary collapse
- #affix? ⇒ Boolean
- #finalize! ⇒ Object
-
#initialize(template, object, builder, options) ⇒ TabsManager
constructor
A new instance of TabsManager.
- #tab(identifier, options = {}, &block) ⇒ Object
- #tabs ⇒ Object
Constructor Details
#initialize(template, object, builder, options) ⇒ TabsManager
Returns a new instance of TabsManager.
15 16 17 18 19 20 |
# File 'lib/para/form_builder/tabs.rb', line 15 def initialize(template, object, builder, ) @template = template @object = object @builder = builder @options = end |
Instance Attribute Details
#builder ⇒ Object (readonly)
Returns the value of attribute builder.
13 14 15 |
# File 'lib/para/form_builder/tabs.rb', line 13 def builder @builder end |
#object ⇒ Object (readonly)
Returns the value of attribute object.
13 14 15 |
# File 'lib/para/form_builder/tabs.rb', line 13 def object @object end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
13 14 15 |
# File 'lib/para/form_builder/tabs.rb', line 13 def @options end |
#template ⇒ Object (readonly)
Returns the value of attribute template.
13 14 15 |
# File 'lib/para/form_builder/tabs.rb', line 13 def template @template end |
Instance Method Details
#affix? ⇒ Boolean
50 51 52 |
# File 'lib/para/form_builder/tabs.rb', line 50 def affix? [:affix] end |
#finalize! ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# 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) ⇒ Object
22 23 24 25 |
# File 'lib/para/form_builder/tabs.rb', line 22 def tab(identifier, = {}, &block) tabs << Tab.new(template, object, builder, identifier, , tabs.length, &block) nil end |
#tabs ⇒ Object
27 28 29 |
# File 'lib/para/form_builder/tabs.rb', line 27 def tabs @tabs ||= [] end |