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, 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, options, index, &content_block)
  @template = template
  @object = object
  @builder = builder
  @identifier = identifier
  @content = capture { content_block.call }
  @icon = options[:icon]
  @active = options[:active]
  @index = index
end

Instance Attribute Details

#activeObject

Returns the value of attribute active.



59
60
61
# File 'lib/para/form_builder/tabs.rb', line 59

def active
  @active
end

#builderObject (readonly)

Returns the value of attribute builder.



56
57
58
# File 'lib/para/form_builder/tabs.rb', line 56

def builder
  @builder
end

#contentObject (readonly)

Returns the value of attribute content.



56
57
58
# File 'lib/para/form_builder/tabs.rb', line 56

def content
  @content
end

#iconObject (readonly)

Returns the value of attribute icon.



56
57
58
# File 'lib/para/form_builder/tabs.rb', line 56

def icon
  @icon
end

#identifierObject (readonly)

Returns the value of attribute identifier.



56
57
58
# File 'lib/para/form_builder/tabs.rb', line 56

def identifier
  @identifier
end

#indexObject (readonly)

Returns the value of attribute index.



56
57
58
# File 'lib/para/form_builder/tabs.rb', line 56

def index
  @index
end

#objectObject (readonly)

Returns the value of attribute object.



56
57
58
# File 'lib/para/form_builder/tabs.rb', line 56

def object
  @object
end

#templateObject (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

Returns:

  • (Boolean)


97
98
99
# File 'lib/para/form_builder/tabs.rb', line 97

def active?
  active == true || (active == nil && index == 0)
end

#dom_idObject



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_nameObject



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

#titleObject



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