Class: Cmtool::Menu::EngineLink

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

Overview

Engine link, links to an engine. Root by default

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from ElementBase

#controller_name, #controller_names, #method_missing, #options, #resource_link?

Constructor Details

#initialize(engine, options = {}) ⇒ EngineLink

Returns a new instance of EngineLink.



97
98
99
# File 'lib/cmtool/menu.rb', line 97

def initialize(engine, options = {})
  @engine, @options = engine, options
end

Dynamic Method Handling

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

Instance Attribute Details

#engineObject (readonly)

Returns the value of attribute engine.



96
97
98
# File 'lib/cmtool/menu.rb', line 96

def engine
  @engine
end

Instance Method Details

#engine_link?Boolean

Returns:

  • (Boolean)


101
102
103
# File 'lib/cmtool/menu.rb', line 101

def engine_link?
  true
end

#pathObject



110
111
112
113
114
115
116
# File 'lib/cmtool/menu.rb', line 110

def path
  case options[:path]
  when Symbol then engine.routes.url_helpers.send(:"#{options[:path]}_path")
  when String then options[:path]
  else engine.routes.url_helpers.root_path
  end
end

#titleObject



106
107
108
# File 'lib/cmtool/menu.rb', line 106

def title
  options[:title] || engine.name.split('::').first
end