Class: MDWA::DSL::Requirements
- Inherits:
-
Object
- Object
- MDWA::DSL::Requirements
- Defined in:
- lib/mdwa/dsl/requirements.rb
Overview
singleton class
Instance Attribute Summary collapse
-
#nodes ⇒ Object
Returns the value of attribute nodes.
Class Method Summary collapse
Instance Method Summary collapse
-
#add_node(node) ⇒ Object
Add note to the entity list Prevents entity duplication.
- #all ⇒ Object
- #clear ⇒ Object
- #element(e) ⇒ Object
-
#initialize ⇒ Requirements
constructor
A new instance of Requirements.
-
#register(summary = nil) {|req| ... } ⇒ Object
Register a new requirement in the list.
Constructor Details
#initialize ⇒ Requirements
Returns a new instance of Requirements.
10 11 12 |
# File 'lib/mdwa/dsl/requirements.rb', line 10 def initialize @nodes ||= {} end |
Instance Attribute Details
#nodes ⇒ Object
Returns the value of attribute nodes.
8 9 10 |
# File 'lib/mdwa/dsl/requirements.rb', line 8 def nodes @nodes end |
Class Method Details
.instance ⇒ Object
14 15 16 |
# File 'lib/mdwa/dsl/requirements.rb', line 14 def self.instance @__instance__ ||= new end |
Instance Method Details
#add_node(node) ⇒ Object
Add note to the entity list Prevents entity duplication
32 33 34 |
# File 'lib/mdwa/dsl/requirements.rb', line 32 def add_node(node) @nodes[node.alias] = node end |
#all ⇒ Object
40 41 42 |
# File 'lib/mdwa/dsl/requirements.rb', line 40 def all @nodes.values end |
#clear ⇒ Object
44 45 46 |
# File 'lib/mdwa/dsl/requirements.rb', line 44 def clear @nodes.clear end |
#element(e) ⇒ Object
36 37 38 |
# File 'lib/mdwa/dsl/requirements.rb', line 36 def element(e) @nodes[e] end |
#register(summary = nil) {|req| ... } ⇒ Object
Register a new requirement in the list.
21 22 23 24 25 26 |
# File 'lib/mdwa/dsl/requirements.rb', line 21 def register( summary = nil ) # retrive or initialize a entity req = Requirement.new( summary ) yield(req) if block_given? add_node(req) # add to the list end |