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.



18
19
20
21
22
23
# File 'lib/pages_core/admin_menu_item.rb', line 18

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.



3
4
5
# File 'lib/pages_core/admin_menu_item.rb', line 3

def group
  @group
end

#labelObject (readonly)

Returns the value of attribute label.



3
4
5
# File 'lib/pages_core/admin_menu_item.rb', line 3

def label
  @label
end

#optionsObject (readonly)

Returns the value of attribute options.



3
4
5
# File 'lib/pages_core/admin_menu_item.rb', line 3

def options
  @options
end

#pathObject (readonly)

Returns the value of attribute path.



3
4
5
# File 'lib/pages_core/admin_menu_item.rb', line 3

def path
  @path
end

Class Method Details

.itemsObject



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

def items
  return [] unless @menu_items
  @menu_items.map { |_, v| v }
end

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



11
12
13
14
15
# File 'lib/pages_core/admin_menu_item.rb', line 11

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



25
26
27
28
29
30
31
# File 'lib/pages_core/admin_menu_item.rb', line 25

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