Class: Kin::Nav::ItemBuilder
- Inherits:
-
Object
- Object
- Kin::Nav::ItemBuilder
- Defined in:
- lib/kin/nav/builder.rb
Overview
Provides the DSL used to create navigation items.
Instance Attribute Summary collapse
-
#item ⇒ Object
readonly
Returns the value of attribute item.
Instance Method Summary collapse
-
#active_on(*pairs) ⇒ Kin::Nav::ItemBuilder
Sets on which controllers and actions the nav item should be considered to be the active item.
-
#guard(guard) ⇒ Kin::Nav::ItemBuilder
Sets a guard condition so that the item is only displayed if the guard is
truewhen the item is rendered. -
#initialize(name, label, menu) ⇒ ItemBuilder
constructor
private
Returns a new Builder instance.
-
#resource(verb) ⇒ Kin::Nav::ItemBuilder
Sets a resource verb to be used to create a URL.
-
#title(title) ⇒ Kin::Nav::ItemBuilder
Sets the (rollover) title applied to the anchor element.
-
#url(url) ⇒ Kin::Nav::ItemBuilder
Sets a URL to be used for the item.
Constructor Details
#initialize(name, label, menu) ⇒ ItemBuilder
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new Builder instance.
79 80 81 82 |
# File 'lib/kin/nav/builder.rb', line 79 def initialize(name, label, ) @item = Item.new(name, label) = end |
Instance Attribute Details
#item ⇒ Object (readonly)
Returns the value of attribute item.
65 66 67 |
# File 'lib/kin/nav/builder.rb', line 65 def item @item end |
Instance Method Details
#active_on(*pairs) ⇒ Kin::Nav::ItemBuilder
Sets on which controllers and actions the nav item should be considered to be the active item.
164 165 166 167 168 169 170 |
# File 'lib/kin/nav/builder.rb', line 164 def active_on(*pairs) pairs.each do |pair| .add_active_match(pair, @item) end self end |
#guard(guard) ⇒ Kin::Nav::ItemBuilder
Sets a guard condition so that the item is only displayed if the guard is true when the item is rendered.
142 143 144 145 |
# File 'lib/kin/nav/builder.rb', line 142 def guard(guard) @item.guard = guard self end |
#resource(verb) ⇒ Kin::Nav::ItemBuilder
Sets a resource verb to be used to create a URL.
109 110 111 112 |
# File 'lib/kin/nav/builder.rb', line 109 def resource(verb) @item.resource = verb self end |
#title(title) ⇒ Kin::Nav::ItemBuilder
Sets the (rollover) title applied to the anchor element.
94 95 96 97 |
# File 'lib/kin/nav/builder.rb', line 94 def title(title) @item.title = title self end |
#url(url) ⇒ Kin::Nav::ItemBuilder
Sets a URL to be used for the item.
124 125 126 127 |
# File 'lib/kin/nav/builder.rb', line 124 def url(url) @item.url = url.to_s self end |