Class: Xebec::NavItem

Inherits:
Object
  • Object
show all
Defined in:
lib/xebec/nav_item.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#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

Instance Attribute Details

#hrefObject (readonly)

Returns the value of attribute href.



5
6
7
# File 'lib/xebec/nav_item.rb', line 5

def href
  @href
end

#html_optionsObject (readonly)

Returns the value of attribute html_options.



5
6
7
# File 'lib/xebec/nav_item.rb', line 5

def html_options
  @html_options
end

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/xebec/nav_item.rb', line 5

def name
  @name
end