Class: Menuizer::Menu::Item

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

Instance Method Summary collapse

Constructor Details

#initialize(public_hash, opts) ⇒ Item

Returns a new instance of Item.



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

def initialize(public_hash,opts)
  super(public_hash)
  @opts = opts
end

Instance Method Details

#pathObject



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

def path
  if @opts[:path]
    @opts[:path]
  else
    if @opts[:title].respond_to?(:model_name) && @opts[:title].model_name.respond_to?(:plural)
      :"#{@opts[:namespace]}#{@opts[:title].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 @opts[:title].respond_to?(:model_name) && @opts[:title].model_name.respond_to?(:human)
    @opts[:title].model_name.human
  else
    @opts[:title]
  end
end