Class: Decidim::Toggle::SettingsTabItem

Inherits:
Object
  • Object
show all
Defined in:
lib/decidim/toggle/settings_tab_item.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(identifier, label, options = {}) ⇒ SettingsTabItem

Returns a new instance of SettingsTabItem.



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/decidim/toggle/settings_tab_item.rb', line 6

def initialize(identifier, label, options = {})
  @identifier = identifier
  @label = label
  @form_layout_partial = options[:form_layout_partial]
  @form_class = options[:form_class]
  @command_class = options[:command_class]
  @position = options[:position] || Float::INFINITY
  @if = options[:if]
  @open = options.fetch(:open, false)
  @module_name = options[:module_name]
end

Instance Attribute Details

#command_classObject (readonly)

Returns the value of attribute command_class.



18
19
20
# File 'lib/decidim/toggle/settings_tab_item.rb', line 18

def command_class
  @command_class
end

#form_classObject (readonly)

Returns the value of attribute form_class.



18
19
20
# File 'lib/decidim/toggle/settings_tab_item.rb', line 18

def form_class
  @form_class
end

#form_layout_partialObject (readonly)

Returns the value of attribute form_layout_partial.



18
19
20
# File 'lib/decidim/toggle/settings_tab_item.rb', line 18

def form_layout_partial
  @form_layout_partial
end

#identifierObject (readonly)

Returns the value of attribute identifier.



18
19
20
# File 'lib/decidim/toggle/settings_tab_item.rb', line 18

def identifier
  @identifier
end

#labelObject (readonly)

Returns the value of attribute label.



18
19
20
# File 'lib/decidim/toggle/settings_tab_item.rb', line 18

def label
  @label
end

#module_nameObject (readonly)

Returns the value of attribute module_name.



18
19
20
# File 'lib/decidim/toggle/settings_tab_item.rb', line 18

def module_name
  @module_name
end

#positionObject

Returns the value of attribute position.



20
21
22
# File 'lib/decidim/toggle/settings_tab_item.rb', line 20

def position
  @position
end

Instance Method Details

#form_tab?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/decidim/toggle/settings_tab_item.rb', line 22

def form_tab?
  form_class.present? && command_class.present?
end

#open?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/decidim/toggle/settings_tab_item.rb', line 26

def open?
  @open
end

#visible?Boolean

Returns:

  • (Boolean)


30
31
32
33
34
# File 'lib/decidim/toggle/settings_tab_item.rb', line 30

def visible?
  return true if @if.nil? || @if

  false
end