Class: Para::FormBuilder::Tabs::Tab

Inherits:
Object
  • Object
show all
Defined in:
lib/para/form_builder/tabs.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(template, object, builder, identifier, options, &content_block) ⇒ Tab

Returns a new instance of Tab.



35
36
37
38
39
40
41
42
# File 'lib/para/form_builder/tabs.rb', line 35

def initialize(template, object, builder, identifier, options, &content_block)
  @template = template
  @object = object
  @builder = builder
  @identifier = identifier
  @content = capture { content_block.call }
  @icon = options[:icon]
end

Instance Attribute Details

#builderObject (readonly)

Returns the value of attribute builder.



31
32
33
# File 'lib/para/form_builder/tabs.rb', line 31

def builder
  @builder
end

#contentObject (readonly)

Returns the value of attribute content.



31
32
33
# File 'lib/para/form_builder/tabs.rb', line 31

def content
  @content
end

#iconObject (readonly)

Returns the value of attribute icon.



31
32
33
# File 'lib/para/form_builder/tabs.rb', line 31

def icon
  @icon
end

#identifierObject (readonly)

Returns the value of attribute identifier.



31
32
33
# File 'lib/para/form_builder/tabs.rb', line 31

def identifier
  @identifier
end

#objectObject (readonly)

Returns the value of attribute object.



31
32
33
# File 'lib/para/form_builder/tabs.rb', line 31

def object
  @object
end

#templateObject (readonly)

Returns the value of attribute template.



31
32
33
# File 'lib/para/form_builder/tabs.rb', line 31

def template
  @template
end

Instance Method Details

#dom_idObject



52
53
54
55
56
57
58
# File 'lib/para/form_builder/tabs.rb', line 52

def dom_id
  @dom_id = [
    'form-tab',
    builder.nested_resource_dom_id.presence,
    identifier.to_s.parameterize
  ].compact.join('-')
end

#titleObject



44
45
46
47
48
49
50
# File 'lib/para/form_builder/tabs.rb', line 44

def title
  if Symbol === identifier
    ::I18n.t("forms.tabs.#{ object.class.model_name.i18n_key }.#{ identifier }")
  else
    identifier
  end
end