Class: AdminSuite::PortalDefinition

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key) ⇒ PortalDefinition

Returns a new instance of PortalDefinition.



9
10
11
12
13
14
15
16
17
18
# File 'lib/admin_suite/portal_definition.rb', line 9

def initialize(key)
  @key = key.to_sym
  @label = nil
  @icon = nil
  @color = nil
  @order = nil
  @description = nil
  @dashboard = nil
  @sections = {}
end

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



7
8
9
# File 'lib/admin_suite/portal_definition.rb', line 7

def key
  @key
end

Instance Method Details

#color(value = nil) ⇒ Object



30
31
32
33
# File 'lib/admin_suite/portal_definition.rb', line 30

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

#dashboard(&block) ⇒ Object



45
46
47
48
49
# File 'lib/admin_suite/portal_definition.rb', line 45

def dashboard(&block)
  @dashboard ||= UI::DashboardDefinition.new
  UI::DashboardDSL.new(@dashboard).instance_eval(&block) if block_given?
  @dashboard
end

#dashboard_definitionObject



51
52
53
# File 'lib/admin_suite/portal_definition.rb', line 51

def dashboard_definition
  @dashboard
end

#description(value = nil) ⇒ Object



40
41
42
43
# File 'lib/admin_suite/portal_definition.rb', line 40

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

#icon(value = nil) ⇒ Object



25
26
27
28
# File 'lib/admin_suite/portal_definition.rb', line 25

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

#label(value = nil) ⇒ Object



20
21
22
23
# File 'lib/admin_suite/portal_definition.rb', line 20

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

#order(value = nil) ⇒ Object



35
36
37
38
# File 'lib/admin_suite/portal_definition.rb', line 35

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

#section(key, &block) ⇒ Object



55
56
57
58
59
# File 'lib/admin_suite/portal_definition.rb', line 55

def section(key, &block)
  definition = (@sections[key.to_sym] ||= SectionDefinition.new(key))
  definition.instance_eval(&block) if block_given?
  definition
end

#sectionsObject



61
62
63
# File 'lib/admin_suite/portal_definition.rb', line 61

def sections
  @sections
end

#to_nav_metaObject



65
66
67
68
69
70
71
72
73
# File 'lib/admin_suite/portal_definition.rb', line 65

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