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) ⇒ 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”

Raises:

  • (ArgumentError)

See Also:

  • ActionView::Helpers::UrlHelper#url_for


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

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

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end