Class: Cmtool::Menu::Group

Inherits:
ElementBase show all
Defined in:
lib/cmtool/menu.rb

Overview

A group element, works as a new kind of menu, but then within another one

Instance Method Summary collapse

Methods inherited from ElementBase

#controller_name, #method_missing, #options

Constructor Details

#initialize(options = {}, &block) ⇒ Group

Returns a new instance of Group.



63
64
65
66
67
68
69
# File 'lib/cmtool/menu.rb', line 63

def initialize(options = {}, &block)
  block ||= Proc.new{}
  @register = Register.new
  @options = options
  @block = block
  @register.instance_eval &block
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Cmtool::Menu::ElementBase

Instance Method Details

#controller_namesObject



74
75
76
# File 'lib/cmtool/menu.rb', line 74

def controller_names
  resource_links.map(&:controller_name)
end

#group?Boolean

Returns:

  • (Boolean)


77
78
79
# File 'lib/cmtool/menu.rb', line 77

def group?
  true
end

#titleObject



70
71
72
# File 'lib/cmtool/menu.rb', line 70

def title
  @register.title.respond_to?(:call) ? @register.title.call : @register.title
end