Class: Vedeu::DSL::Group
- Inherits:
-
Object
- Object
- Vedeu::DSL::Group
- Includes:
- Vedeu::DSL
- Defined in:
- lib/vedeu/dsl/group.rb
Overview
DSL for adding interfaces to a group.
Instance Attribute Summary collapse
- #client ⇒ Object readonly protected
- #model ⇒ Group readonly protected
Class Method Summary collapse
-
.group(name, &block) ⇒ Vedeu::Group
Specify a new group of interfaces with a simple DSL.
Instance Method Summary collapse
-
#add(interface_name) ⇒ void
Add the named interface to this group.
-
#initialize(model, client = nil) ⇒ Vedeu::DSL::Group
constructor
Returns an instance of DSL::Group.
Methods included from Vedeu::DSL
Constructor Details
#initialize(model, client = nil) ⇒ Vedeu::DSL::Group
Returns an instance of DSL::Group.
45 46 47 48 |
# File 'lib/vedeu/dsl/group.rb', line 45 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)
62 63 64 |
# File 'lib/vedeu/dsl/group.rb', line 62 def client @client end |
#model ⇒ Group (readonly, protected)
66 67 68 |
# File 'lib/vedeu/dsl/group.rb', line 66 def model @model end |
Class Method Details
.group(name, &block) ⇒ Vedeu::Group
Note:
Creating a group with the same name as an existing group overwrites the existing group.
Specify a new group of interfaces with a simple DSL.
The example below resembles ‘vim’ (the popular terminal-based text editor):
34 35 36 37 38 |
# File 'lib/vedeu/dsl/group.rb', line 34 def self.group(name, &block) fail InvalidSyntax, 'block not given' unless block_given? Vedeu::Group.build({ name: name }, &block).store end |
Instance Method Details
#add(interface_name) ⇒ void
This method returns an undefined value.
Add the named interface to this group.
54 55 56 |
# File 'lib/vedeu/dsl/group.rb', line 54 def add(interface_name) model.add(interface_name) end |