Class: Para::FormBuilder::Tabs::Tab
- Inherits:
-
Object
- Object
- Para::FormBuilder::Tabs::Tab
- Defined in:
- lib/para/form_builder/tabs.rb
Instance Attribute Summary collapse
-
#active ⇒ Object
Returns the value of attribute active.
-
#builder ⇒ Object
readonly
Returns the value of attribute builder.
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#icon ⇒ Object
readonly
Returns the value of attribute icon.
-
#identifier ⇒ Object
readonly
Returns the value of attribute identifier.
-
#index ⇒ Object
readonly
Returns the value of attribute index.
-
#object ⇒ Object
readonly
Returns the value of attribute object.
-
#template ⇒ Object
readonly
Returns the value of attribute template.
Instance Method Summary collapse
- #active? ⇒ Boolean
- #dom_id ⇒ Object
-
#initialize(template, object, builder, identifier, options, index, &content_block) ⇒ Tab
constructor
A new instance of Tab.
- #object_name ⇒ Object
- #title ⇒ Object
Constructor Details
#initialize(template, object, builder, identifier, options, index, &content_block) ⇒ Tab
Returns a new instance of Tab.
63 64 65 66 67 68 69 70 71 72 |
# File 'lib/para/form_builder/tabs.rb', line 63 def initialize(template, object, builder, identifier, , index, &content_block) @template = template @object = object @builder = builder @identifier = identifier @content = capture { content_block.call } @icon = [:icon] @active = [:active] @index = index end |
Instance Attribute Details
#active ⇒ Object
Returns the value of attribute active.
59 60 61 |
# File 'lib/para/form_builder/tabs.rb', line 59 def active @active end |
#builder ⇒ Object (readonly)
Returns the value of attribute builder.
56 57 58 |
# File 'lib/para/form_builder/tabs.rb', line 56 def builder @builder end |
#content ⇒ Object (readonly)
Returns the value of attribute content.
56 57 58 |
# File 'lib/para/form_builder/tabs.rb', line 56 def content @content end |
#icon ⇒ Object (readonly)
Returns the value of attribute icon.
56 57 58 |
# File 'lib/para/form_builder/tabs.rb', line 56 def icon @icon end |
#identifier ⇒ Object (readonly)
Returns the value of attribute identifier.
56 57 58 |
# File 'lib/para/form_builder/tabs.rb', line 56 def identifier @identifier end |
#index ⇒ Object (readonly)
Returns the value of attribute index.
56 57 58 |
# File 'lib/para/form_builder/tabs.rb', line 56 def index @index end |
#object ⇒ Object (readonly)
Returns the value of attribute object.
56 57 58 |
# File 'lib/para/form_builder/tabs.rb', line 56 def object @object end |
#template ⇒ Object (readonly)
Returns the value of attribute template.
56 57 58 |
# File 'lib/para/form_builder/tabs.rb', line 56 def template @template end |
Instance Method Details
#active? ⇒ Boolean
97 98 99 |
# File 'lib/para/form_builder/tabs.rb', line 97 def active? active == true || (active == nil && index == 0) end |
#dom_id ⇒ Object
82 83 84 85 86 87 88 89 |
# File 'lib/para/form_builder/tabs.rb', line 82 def dom_id @dom_id = [ 'form-tab', object_name, builder.nested_resource_dom_id.presence, identifier.to_s.parameterize ].compact.join('-') end |
#object_name ⇒ Object
91 92 93 94 95 |
# File 'lib/para/form_builder/tabs.rb', line 91 def object_name if (name = builder.object_name.presence) name.to_s.parameterize end end |
#title ⇒ Object
74 75 76 77 78 79 80 |
# File 'lib/para/form_builder/tabs.rb', line 74 def title if Symbol === identifier ::I18n.t("forms.tabs.#{ object.class.model_name.i18n_key }.#{ identifier }") else identifier end end |