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 private
- #model ⇒ Menu readonly private
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.
19 20 21 22 |
# File 'lib/vedeu/dsl/components/menu.rb', line 19 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, private)
79 80 81 |
# File 'lib/vedeu/dsl/components/menu.rb', line 79 def client @client end |
#model ⇒ Menu (readonly, private)
82 83 84 |
# File 'lib/vedeu/dsl/components/menu.rb', line 82 def model @model end |
Instance Method Details
#item(element) ⇒ Array
Add an individual item to the menu.
34 35 36 |
# File 'lib/vedeu/dsl/components/menu.rb', line 34 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.
57 58 59 |
# File 'lib/vedeu/dsl/components/menu.rb', line 57 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.
72 73 74 |
# File 'lib/vedeu/dsl/components/menu.rb', line 72 def name(value) model.name = value end |