Class: Serial::Builder Private

Inherits:
Object
  • Object
show all
Defined in:
lib/serial/builder.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Builder contains common methods to the serializer DSL.

API:

  • private

Direct Known Subclasses

ArrayBuilder, HashBuilder

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#dataArray, Hash (readonly)

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.

Builder data, depends on what kind of builder it is.

Returns:

API:

  • private



22
23
24
# File 'lib/serial/builder.rb', line 22

def data
  @data
end

Class Method Details

.build(context, *args) {|self, *args| ... } ⇒ #data

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.

Create the builder, execute the block inside it, and return its’ data. Any superflous arguments are given to #exec.

Parameters:

  • the context to execute block inside

Yields:

  • (self, *args)

Yield Parameters:

  • self (Builder)

    passes in self as the first parameter.

  • *args

    superflous arguments are passed to the block.

Returns:

API:

  • private



13
14
15
16
17
# File 'lib/serial/builder.rb', line 13

def self.build(context, *args, &block)
  builder = new(context)
  builder.exec(*args, &block)
  builder.data
end

Instance Method Details

#exec(*args) {|self, *args| ... } ⇒ Object

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.

Executes a block in the configured context, if there is one, otherwise using regular closure scoping.

Yields:

  • (self, *args)

Yield Parameters:

  • self (Builder)

    passes in self as the first parameter.

  • *args

    superflous arguments are passed to the block.

API:

  • private



30
31
32
33
34
35
36
37
38
# File 'lib/serial/builder.rb', line 30

def exec(*args, &block)
  if @context
    @context.instance_exec(self, *args, &block)
  elsif block
    block.call(self, *args)
  else
    raise ArgumentError, "no serializer block given"
  end
end