Class: Protoform::NamespaceCollection
- Includes:
- Enumerable
- Defined in:
- lib/protoform/namespace_collection.rb
Instance Attribute Summary
Attributes inherited from Node
Instance Method Summary collapse
- #assign(array) ⇒ Object
- #each(&block) ⇒ Object
-
#initialize(key, parent:, field_class:, &template) ⇒ NamespaceCollection
constructor
A new instance of NamespaceCollection.
- #serialize ⇒ Object
Constructor Details
#initialize(key, parent:, field_class:, &template) ⇒ NamespaceCollection
Returns a new instance of NamespaceCollection.
7 8 9 10 11 12 |
# File 'lib/protoform/namespace_collection.rb', line 7 def initialize(key, parent:, field_class:, &template) super(key, parent:) @template = template @field_class = field_class @namespaces = enumerate(parent_collection) end |
Instance Method Details
#assign(array) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/protoform/namespace_collection.rb', line 18 def assign(array) # The problem with zip-ing the array is if I need to add new # elements to it and wrap it in the namespace. zip(array) do |namespace, hash| namespace.assign hash end end |
#each(&block) ⇒ Object
26 27 28 |
# File 'lib/protoform/namespace_collection.rb', line 26 def each(&block) @namespaces.each(&block) end |
#serialize ⇒ Object
14 15 16 |
# File 'lib/protoform/namespace_collection.rb', line 14 def serialize map(&:serialize) end |