Class: MDWA::DSL::Entities
- Inherits:
-
Object
- Object
- MDWA::DSL::Entities
- Defined in:
- lib/mdwa/dsl/entities.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
- #element(e) ⇒ Object
-
#initialize ⇒ Entities
constructor
A new instance of Entities.
-
#register(name) {|entity| ... } ⇒ Object
Register a new entity in the list.
Constructor Details
#initialize ⇒ Entities
Returns a new instance of Entities.
10 11 12 |
# File 'lib/mdwa/dsl/entities.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/entities.rb', line 8 def nodes @nodes end |
Class Method Details
.instance ⇒ Object
14 15 16 |
# File 'lib/mdwa/dsl/entities.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
33 34 35 |
# File 'lib/mdwa/dsl/entities.rb', line 33 def add_node(node) @nodes[node.name] = node end |
#all ⇒ Object
41 42 43 |
# File 'lib/mdwa/dsl/entities.rb', line 41 def all @nodes.values end |
#element(e) ⇒ Object
37 38 39 |
# File 'lib/mdwa/dsl/entities.rb', line 37 def element(e) @nodes[e] end |
#register(name) {|entity| ... } ⇒ Object
Register a new entity in the list.
21 22 23 24 25 26 27 |
# File 'lib/mdwa/dsl/entities.rb', line 21 def register( name ) # retrive or initialize a entity entity = element(name) || Entity.new( name ) yield(entity) if block_given? entity.after_declaration add_node entity # add to the list end |