class Serial::ArrayBuilder
A builder for building arrays. You most likely just want to look at the public API methods in this class.
Public Class Methods
new(context)
click to toggle source
@api private
# File lib/serial/array_builder.rb, line 6 def initialize(context) @context = context @data = [] end
Public Instance Methods
collection(&block)
click to toggle source
@api public Serializes a collection in a collection.
@example
h.collection(…) do |l| l.collection do |l| l.element { … } end end
@yield [builder] @yieldparam builder [ArrayBuilder]
# File lib/serial/array_builder.rb, line 39 def collection(&block) @data << ArrayBuilder.build(@context, &block) end
element(&block)
click to toggle source
@api public Serializes a hash item in a collection.
@example
h.collection(…) do |l| l.element do |h| h.attribute(…) end end
@yield [builder] @yieldparam builder [HashBuilder]
# File lib/serial/array_builder.rb, line 23 def element(&block) @data << HashBuilder.build(@context, &block) end