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