Class: Serial::ArrayBuilder
- Defined in:
- lib/serial/array_builder.rb
Overview
A builder for building arrays. You most likely just want to look at the public API methods in this class.
Instance Attribute Summary
Attributes inherited from Builder
Instance Method Summary collapse
-
#collection {|builder| ... } ⇒ Object
Serializes a collection in a collection.
-
#element {|builder| ... } ⇒ Object
Serializes a hash item in a collection.
-
#initialize(context) ⇒ ArrayBuilder
constructor
private
A new instance of ArrayBuilder.
Methods inherited from Builder
Constructor Details
permalink #initialize(context) ⇒ ArrayBuilder
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of ArrayBuilder.
6 7 8 9 |
# File 'lib/serial/array_builder.rb', line 6 def initialize(context) @context = context @data = [] end |
Instance Method Details
permalink #collection {|builder| ... } ⇒ Object
Serializes a collection in a collection.
39 40 41 |
# File 'lib/serial/array_builder.rb', line 39 def collection(&block) @data << ArrayBuilder.build(@context, &block) end |
permalink #element {|builder| ... } ⇒ Object
Serializes a hash item in a collection.
23 24 25 |
# File 'lib/serial/array_builder.rb', line 23 def element(&block) @data << HashBuilder.build(@context, &block) end |