Class: ActionNav::ItemDSL
- Inherits:
-
Object
- Object
- ActionNav::ItemDSL
- Defined in:
- lib/action_nav/item_dsl.rb
Instance Method Summary collapse
- #count(&block) ⇒ Object
- #description(description = nil, &block) ⇒ Object
- #hide_unless(&block) ⇒ Object
- #icon(icon = nil, &block) ⇒ Object
-
#initialize(item) ⇒ ItemDSL
constructor
A new instance of ItemDSL.
- #item(id, &block) ⇒ Object
- #meta(meta = {}, &block) ⇒ Object
- #title(title = nil, &block) ⇒ Object
- #url(url = nil, &block) ⇒ Object
Constructor Details
#initialize(item) ⇒ ItemDSL
Returns a new instance of ItemDSL.
4 5 6 |
# File 'lib/action_nav/item_dsl.rb', line 4 def initialize(item) @item = item end |
Instance Method Details
#count(&block) ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/action_nav/item_dsl.rb', line 38 def count(&block) if block_given? @item.count = block else raise ArgumentError, "Block must be provided to `count`" end end |
#description(description = nil, &block) ⇒ Object
16 17 18 |
# File 'lib/action_nav/item_dsl.rb', line 16 def description(description = nil, &block) @item.description = block_given? ? block : description end |
#hide_unless(&block) ⇒ Object
28 29 30 |
# File 'lib/action_nav/item_dsl.rb', line 28 def hide_unless(&block) @item.hide_unless = block end |
#icon(icon = nil, &block) ⇒ Object
20 21 22 |
# File 'lib/action_nav/item_dsl.rb', line 20 def icon(icon = nil, &block) @item.icon = block_given? ? block : icon end |
#item(id, &block) ⇒ Object
32 33 34 35 36 |
# File 'lib/action_nav/item_dsl.rb', line 32 def item(id, &block) child = @item.add_child(id) child.dsl(&block) child end |
#meta(meta = {}, &block) ⇒ Object
24 25 26 |
# File 'lib/action_nav/item_dsl.rb', line 24 def ( = {}, &block) @item. = block_given? ? block : end |
#title(title = nil, &block) ⇒ Object
8 9 10 |
# File 'lib/action_nav/item_dsl.rb', line 8 def title(title = nil, &block) @item.title = block_given? ? block : title end |
#url(url = nil, &block) ⇒ Object
12 13 14 |
# File 'lib/action_nav/item_dsl.rb', line 12 def url(url = nil, &block) @item.url = block_given? ? block : url end |