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



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
28
29
# File 'lib/menuizer/menu/item.rb', line 14

def path
  unless path = @opts[:path]
    case item
    when Symbol
      path = [item.to_s.pluralize.to_sym]
    end
  end

  if path
    if namespace
      [namespace[0..-2].to_sym,*path]
    else
      path
    end
  end
end

#titleObject



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

def title
  if title = @opts[:title]
    @opts[:title]
  else
    I18n.translate :"#{namespace}menuizer.#{item}", default: [:"activerecord.models.#{item}", "#{item}"]
  end
end