Class: AdminSuite::SectionDefinition

Inherits:
Object
  • Object
show all
Defined in:
lib/admin_suite/section_definition.rb

Overview

A navigation section within a portal. Sections group resources in the sidebar; declaring one lets a portal control its label, icon and order instead of accepting the humanized key and alphabetical placement.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key) ⇒ SectionDefinition

Returns a new instance of SectionDefinition.



10
11
12
13
14
15
16
# File 'lib/admin_suite/section_definition.rb', line 10

def initialize(key)
  @key = key.to_sym
  @label = nil
  @icon = nil
  @order = nil
  @description = nil
end

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



8
9
10
# File 'lib/admin_suite/section_definition.rb', line 8

def key
  @key
end

Instance Method Details

#description(value = nil) ⇒ Object



33
34
35
36
# File 'lib/admin_suite/section_definition.rb', line 33

def description(value = nil)
  @description = value if value.present?
  @description
end

#icon(value = nil) ⇒ Object



23
24
25
26
# File 'lib/admin_suite/section_definition.rb', line 23

def icon(value = nil)
  @icon = value if value.present?
  @icon
end

#label(value = nil) ⇒ Object



18
19
20
21
# File 'lib/admin_suite/section_definition.rb', line 18

def label(value = nil)
  @label = value if value.present?
  @label
end

#order(value = nil) ⇒ Object



28
29
30
31
# File 'lib/admin_suite/section_definition.rb', line 28

def order(value = nil)
  @order = value unless value.nil?
  @order
end

#to_nav_metaObject



38
39
40
# File 'lib/admin_suite/section_definition.rb', line 38

def to_nav_meta
  { label: @label, icon: @icon, order: @order, description: @description }.compact
end