Class: Vedeu::Groups::DSL
- Inherits:
-
Object
- Object
- Vedeu::Groups::DSL
- Includes:
- DSL
- Defined in:
- lib/vedeu/groups/dsl.rb
Overview
Interfaces can be configured to be part of a named group. Once an interface is a member of group, the group can be affected by other controls. For example, assuming the client application is a simple Git client, it may have a group called ‘commit’. The ‘commit’ group will contain the interfaces ‘diff’ (to show the changes), ‘staged’ (to show which files are staged) and ‘unstaged’. A refresh of the ‘commit’ group would cause all interfaces belonging to the group to refresh. Similarly, showing or hiding the group would of course, show or hide the interfaces of that group.
Instance Attribute Summary
Attributes included from DSL
Class Method Summary collapse
-
.group(name, &block) ⇒ Vedeu::Groups::Group
Specify a new group of interfaces with a simple DSL.
Instance Method Summary collapse
-
#add(name) ⇒ Vedeu::Groups::Group
Add the named interface to this group.
-
#members(*names) ⇒ Array<String>
Add the named interfaces to this group in bulk.
Methods included from DSL
#attributes, #initialize, #method_missing, #name
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Vedeu::DSL
Class Method Details
.group(name, &block) ⇒ Vedeu::Groups::Group
Specify a new group of interfaces with a simple DSL. Creating a group with the same name as an existing group overwrites the existing group.
The example below resembles ‘vim’ (the popular terminal-based text editor):
Vedeu.group :title_screen do
add :welcome_interface
# ... some code
end
Vedeu.group :main_screen do
add :editor_interface
add :status_interface
add :command_interface
# ... some code
end
or more succinctly:
Vedeu.group :main_screen do
members :editor_interface,
:status_interface,
:command_interface
# ... some code
end
or when defining an interface:
Vedeu.interface :some_interface do
group :some_group
# ... some code
end
63 64 65 66 67 68 |
# File 'lib/vedeu/groups/dsl.rb', line 63 def self.group(name, &block) raise Vedeu::Error::MissingRequired unless name raise Vedeu::Error::RequiresBlock unless block_given? Vedeu::Groups::Group.build(name: name, &block).store end |
Instance Method Details
#add(name) ⇒ Vedeu::Groups::Group
78 79 80 |
# File 'lib/vedeu/groups/dsl.rb', line 78 def add(name) model.add(name) end |