Class: Superform::NamespaceCollection
- Includes:
- Enumerable
- Defined in:
- lib/superform.rb
Instance Attribute Summary
Attributes inherited from Node
Instance Method Summary collapse
- #assign(array) ⇒ Object
- #each ⇒ Object
-
#initialize(key, parent:, &template) ⇒ NamespaceCollection
constructor
A new instance of NamespaceCollection.
- #serialize ⇒ Object
Constructor Details
#initialize(key, parent:, &template) ⇒ NamespaceCollection
Returns a new instance of NamespaceCollection.
264 265 266 267 268 |
# File 'lib/superform.rb', line 264 def initialize(key, parent:, &template) super(key, parent: parent) @template = template @namespaces = enumerate(parent_collection) end |
Instance Method Details
#assign(array) ⇒ Object
274 275 276 277 278 279 280 |
# File 'lib/superform.rb', line 274 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 ⇒ Object
282 283 284 |
# File 'lib/superform.rb', line 282 def each(&) @namespaces.each(&) end |
#serialize ⇒ Object
270 271 272 |
# File 'lib/superform.rb', line 270 def serialize map(&:serialize) end |