Class: NxtSchema::Template::SubNodes
- Inherits:
-
Hash
- Object
- Hash
- NxtSchema::Template::SubNodes
- Defined in:
- lib/nxt_schema/template/sub_nodes.rb
Instance Method Summary collapse
- #add(node) ⇒ Object
- #ensure_node_name_free(name) ⇒ Object
-
#initialize ⇒ SubNodes
constructor
A new instance of SubNodes.
Constructor Details
#initialize ⇒ SubNodes
Returns a new instance of SubNodes.
4 5 6 7 |
# File 'lib/nxt_schema/template/sub_nodes.rb', line 4 def initialize super transform_keys { |k| k.to_sym } end |
Instance Method Details
#add(node) ⇒ Object
9 10 11 12 13 |
# File 'lib/nxt_schema/template/sub_nodes.rb', line 9 def add(node) node_name = node.name ensure_node_name_free(node_name) self[node_name] = node end |
#ensure_node_name_free(name) ⇒ Object
15 16 17 18 19 |
# File 'lib/nxt_schema/template/sub_nodes.rb', line 15 def ensure_node_name_free(name) return unless key?(name) raise KeyError, "Node with name '#{name}' already exists! Node names must be unique!" end |