Class: Vedeu::Menus::DSL
Overview
Provides the mechanism to create menus within client applications and use events to drive them.
Instance Attribute Summary
Attributes included from DSL
Instance Method Summary collapse
-
#initialize(model, client = nil) ⇒ Vedeu::Menus::DSL
constructor
Return a new instance of Vedeu::Menus::DSL.
-
#item(element) ⇒ Array
(also: #item=)
Add an individual item to the menu.
-
#items(collection = []) ⇒ Array
(also: #items=)
Define the items for the menu.
-
#name(value) ⇒ String
(also: #name=)
The name of the menu.
Methods included from DSL
Constructor Details
#initialize(model, client = nil) ⇒ Vedeu::Menus::DSL
Return a new instance of Vedeu::Menus::DSL.
17 18 19 20 |
# File 'lib/vedeu/menus/dsl.rb', line 17 def initialize(model, client = nil) @model = model @client = client end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Vedeu::DSL
Instance Method Details
#item(element) ⇒ Array Also known as: item=
Add an individual item to the menu.
33 34 35 |
# File 'lib/vedeu/menus/dsl.rb', line 33 def item(element) model.collection << element end |
#items(collection = []) ⇒ Array Also known as: items=
Define the items for the menu. Most powerful when used with one of your model classes.
In the ‘my_playlist’ example below, your ‘Track` model may return a collection of tracks to populate the menu.
Vedeu. 'my_menu' do
items [:item_1, :item_2, :item_3]
end
Vedeu. 'my_playlist' do
items Track.all_my_favourites
end
55 56 57 |
# File 'lib/vedeu/menus/dsl.rb', line 55 def items(collection = []) model.collection = collection end |
#name(value) ⇒ String Also known as: name=
The name of the menu. Used to reference the menu throughout your application’s execution lifetime.
Vedeu. do
name 'my_menu'
# ...
end
70 71 72 |
# File 'lib/vedeu/menus/dsl.rb', line 70 def name(value) model.name = value end |