Class: Menuizer::Menu::Item

Inherits:
OpenStruct
  • Object
show all
Defined in:
lib/menuizer/menu/item.rb

Instance Method Summary collapse

Constructor Details

#initialize(opts) ⇒ Item

Returns a new instance of Item.



2
3
4
5
# File 'lib/menuizer/menu/item.rb', line 2

def initialize(opts)
  super
  @opts = opts
end

Instance Method Details

#pathObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/menuizer/menu/item.rb', line 14

def path
  if path = @opts[:path]
    if path.respond_to?(:unshift)
      if namespace
        path = [namespace[0..-2].to_sym,*path]
      end
    end
    path
  else
    if model && model.model_name.respond_to?(:plural)
      :"#{namespace}#{model.model_name.plural}"
    end
  end
end

#titleObject



7
8
9
10
11
12
13
# File 'lib/menuizer/menu/item.rb', line 7

def title
  if model && model.model_name.respond_to?(:human)
    model.model_name.human
  else
    @opts[:title]
  end
end