Method: Xebec::NavItem#initialize

Defined in:
lib/xebec/nav_item.rb

#initialize(name, href = nil, html_options = {}) ⇒ NavItem

Create a new navigation item.

Parameters:

  • name (String, Symbol)

    the name of the item

  • href (String, Hash, ActiveRecord::Base) (defaults to: nil)

    whither the navigation item links; defaults to the named route, “##name_path”

  • html_options (Hash) (defaults to: {})

    to be passed to the link_to helper method

Raises:

  • (ArgumentError)

See Also:

  • ActionView::Helpers::UrlHelper#url_for


15
16
17
18
# File 'lib/xebec/nav_item.rb', line 15

def initialize(name, href = nil, html_options = {})
  raise ArgumentError.new("#{name || '<nil>'} is not a valid name for a navigation item") if name.blank?
  @name, @href, @html_options = name, href, html_options
end