Class: PagesCore::AdminMenuItem

Inherits:
Object
  • Object
show all
Defined in:
lib/pages_core/admin_menu_item.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(label, path, group = :custom, options = {}) ⇒ AdminMenuItem

Returns a new instance of AdminMenuItem.



21
22
23
24
25
26
# File 'lib/pages_core/admin_menu_item.rb', line 21

def initialize(label, path, group = :custom, options = {})
  @label = label
  @path = path
  @group = group
  @options = options
end

Instance Attribute Details

#groupObject (readonly)

Returns the value of attribute group.



5
6
7
# File 'lib/pages_core/admin_menu_item.rb', line 5

def group
  @group
end

#labelObject (readonly)

Returns the value of attribute label.



5
6
7
# File 'lib/pages_core/admin_menu_item.rb', line 5

def label
  @label
end

#optionsObject (readonly)

Returns the value of attribute options.



5
6
7
# File 'lib/pages_core/admin_menu_item.rb', line 5

def options
  @options
end

#pathObject (readonly)

Returns the value of attribute path.



5
6
7
# File 'lib/pages_core/admin_menu_item.rb', line 5

def path
  @path
end

Class Method Details

.itemsObject



8
9
10
11
12
# File 'lib/pages_core/admin_menu_item.rb', line 8

def items
  return [] unless @menu_items

  @menu_items.map { |_, v| v }
end

.register(label, path, group = :custom, options = {}) ⇒ Object



14
15
16
17
18
# File 'lib/pages_core/admin_menu_item.rb', line 14

def register(label, path, group = :custom, options = {})
  entry = new(label, path, group, options)
  @menu_items ||= {}
  @menu_items[[group, label]] = entry
end

Instance Method Details

#==(other) ⇒ Object



28
29
30
31
32
33
34
# File 'lib/pages_core/admin_menu_item.rb', line 28

def ==(other)
  other &&
    other.label == label &&
    other.path == path &&
    other.group == group &&
    other.options == options
end