Class: Avo::Resources::Items::TabGroup::Builder
- Inherits:
-
Object
- Object
- Avo::Resources::Items::TabGroup::Builder
- Defined in:
- lib/avo/resources/items/tab_group.rb
Instance Attribute Summary collapse
-
#items_holder ⇒ Object
readonly
Returns the value of attribute items_holder.
Class Method Summary collapse
Instance Method Summary collapse
-
#build ⇒ Object
Fetch the tab.
- #field(field_name, **args, &block) ⇒ Object
-
#initialize(style: nil) ⇒ Builder
constructor
A new instance of Builder.
Constructor Details
Instance Attribute Details
#items_holder ⇒ Object (readonly)
Returns the value of attribute items_holder.
33 34 35 |
# File 'lib/avo/resources/items/tab_group.rb', line 33 def items_holder @items_holder end |
Class Method Details
.parse_block(**args, &block) ⇒ Object
28 29 30 |
# File 'lib/avo/resources/items/tab_group.rb', line 28 def parse_block(**args, &block) Docile.dsl_eval(new(**args), &block).build end |
Instance Method Details
#build ⇒ Object
Fetch the tab
63 64 65 66 |
# File 'lib/avo/resources/items/tab_group.rb', line 63 def build @group.items_holder = @items_holder @group end |
#field(field_name, **args, &block) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/avo/resources/items/tab_group.rb', line 42 def field(field_name, **args, &block) parsed = Avo::Dsl::FieldParser.new(id: field_name, order_index: @items_index, **args, &block).parse field_instance = parsed.instance name = field_instance.name tab = Avo::Resources::Items::Tab.new name: name if field_instance.has_own_panel? tab.items_holder.add_item parsed.instance else # If the field is not in a panel, create one and add it panel = Avo::Resources::Items::Panel.new name: name panel.items_holder.add_item parsed.instance # Add that panel to the items_holder tab.items_holder.add_item panel end @items_holder.tabs tab end |