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, #engine_link?, #method_missing, #options, #resource_link?

Constructor Details

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

Returns a new instance of Group.



72
73
74
75
76
77
78
# File 'lib/cmtool/menu.rb', line 72

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



84
85
86
# File 'lib/cmtool/menu.rb', line 84

def controller_names
  resource_links.map(&:controller_name)
end

#group?Boolean

Returns:

  • (Boolean)


87
88
89
# File 'lib/cmtool/menu.rb', line 87

def group?
  true
end

#titleObject



80
81
82
# File 'lib/cmtool/menu.rb', line 80

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