Class: Vedeu::DSL::Menu
- Inherits:
-
Object
- Object
- Vedeu::DSL::Menu
- Includes:
- Vedeu::DSL
- Defined in:
- lib/vedeu/dsl/components/menu.rb
Overview
Provides the mechanism to create menus within client applications and use events to drive them.
Instance Attribute Summary collapse
- #client ⇒ Object readonly protected
- #model ⇒ Vedeu::Menu readonly protected
Instance Method Summary collapse
-
#initialize(model, client = nil) ⇒ Vedeu::DSL::Menu
constructor
Return a new instance of DSL::Menu.
-
#item(element) ⇒ Array
Add an individual item to the menu.
-
#items(collection = []) ⇒ Array
Define the items for the menu.
-
#name(value) ⇒ String
The name of the menu.
Methods included from Vedeu::DSL
Constructor Details
#initialize(model, client = nil) ⇒ Vedeu::DSL::Menu
Return a new instance of DSL::Menu.
18 19 20 21 |
# File 'lib/vedeu/dsl/components/menu.rb', line 18 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 Attribute Details
#client ⇒ Object (readonly, protected)
79 80 81 |
# File 'lib/vedeu/dsl/components/menu.rb', line 79 def client @client end |
#model ⇒ Vedeu::Menu (readonly, protected)
83 84 85 |
# File 'lib/vedeu/dsl/components/menu.rb', line 83 def model @model end |
Instance Method Details
#item(element) ⇒ Array
Add an individual item to the menu.
33 34 35 |
# File 'lib/vedeu/dsl/components/menu.rb', line 33 def item(element) model.collection << element end |
#items(collection = []) ⇒ Array
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.
56 57 58 |
# File 'lib/vedeu/dsl/components/menu.rb', line 56 def items(collection = []) model.collection = collection end |
#name(value) ⇒ String
The name of the menu. Used to reference the menu throughout your application’s execution lifetime.
71 72 73 |
# File 'lib/vedeu/dsl/components/menu.rb', line 71 def name(value) model.name = value end |